iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Tags
child page refresh parent

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-23-2009, 05:14 PM
WebProWorld Pro
 
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 265
getmea RepRank 1
Default Close a child page and refresh parent page

Hey, I have a "how to" question.

On my site, visitors are able to view a larger-sized image (a popup) of a product by clicking on the image. Clicking on the "add to cart" button allows them to add the item to their cart from the popup. I currently have it programmed to redirect to the cart page (of which I don't mind changing). It doesn't look good when the cart page appears in the same 300x400 child page.

I'd like to have the popup add the item to the cart, close the page, and issue a "refresh" of the parent page -- so the cart $$$ can be updated. Most of the site is PHP driven.

Any ideas?

John
Reply With Quote
  #2 (permalink)  
Old 08-23-2009, 06:36 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 254
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Close a child page and refresh parent page

I've just been experimenting and have a solution.

The form currently embedded in the popup window needs to be moved to the main page and hidden. Remove the submit button and also remove the forms action attribute which currently calls update-cart.php with the appended sku.

In the main page - write a javascript function that accepts a variable passed to it - BuyItem(sku)?
In this function
close the popup window
read the sku that's been passed
define and set the action attribute of the hidden form to call update-cart.php plus the sku etc
submit the form

In the popup window
set the Buy Now button to call the parent windows BuyItem function with the sku of the product.
clue - window.opener.BuyItem(sku)

Hope this helps - ask for more if needed.

Last edited by Uncle Dog; 08-23-2009 at 07:05 PM.
Reply With Quote
  #3 (permalink)  
Old 08-23-2009, 08:57 PM
WebProWorld Pro
 
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 265
getmea RepRank 1
Default Re: Close a child page and refresh parent page

Hi, Uncle Dog...

Great tip! Thanks...

I've implemented the changes but nothing happens when I click on the "Add to cart" button. I set Add To Cart as an anchor:

<a onClick="javascript:window.opener.fnAddToCart('BDG C11C',1);" href="javascript:void(1)">

<img alt="Add to your personal shopping cart image" src="../img/add-to-cart.gif" width="60" height="20" />

</a>

Something wrong?

John
Reply With Quote
  #4 (permalink)  
Old 08-23-2009, 09:04 PM
williamc's Avatar
WebProWorld 1,000+ Club
WebProWorld MVP
 
Join Date: Jul 2003
Location: GoogleVille
Posts: 1,585
williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7
Default Re: Close a child page and refresh parent page

why not just have ajax submit the item to the cart, refresh the parent, close the popup upon clicking to add?
__________________
William Cross
Expert Search Engine Optimization
Reply With Quote
  #5 (permalink)  
Old 08-23-2009, 09:06 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 254
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Close a child page and refresh parent page

getmea - something wrong? Yes. It should be

<a href="javascript:window.opener.fnAddToCart('BDG C11C',1);">

EDIT: apologies. on closer inspection - your way was OK. I knee-jerked to a personal preference.

Last edited by Uncle Dog; 08-23-2009 at 10:31 PM.
Reply With Quote
  #6 (permalink)  
Old 08-23-2009, 09:30 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 254
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Close a child page and refresh parent page

Quote:
Originally Posted by williamc View Post
why not just have ajax submit the item to the cart, refresh the parent, close the popup upon clicking to add?
Why use AJAX when I only need to use J?

Last edited by Uncle Dog; 08-23-2009 at 09:39 PM.
Reply With Quote
  #7 (permalink)  
Old 08-23-2009, 10:03 PM
williamc's Avatar
WebProWorld 1,000+ Club
WebProWorld MVP
 
Join Date: Jul 2003
Location: GoogleVille
Posts: 1,585
williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7williamc RepRank 7
Default Re: Close a child page and refresh parent page

Your way works as well. I just prefer ajax's background processing and no need of multiple output pages in the popup.
__________________
William Cross
Expert Search Engine Optimization
Reply With Quote
  #8 (permalink)  
Old 08-23-2009, 10:27 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 254
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Close a child page and refresh parent page

getmea - in your new function you are trying to close productpreviewwindow (it doesn't exist). It should be productPreviewWindow. That's where your code is hanging.

EDIT - hope you don't mind me revisiting your dev' site. I guessed that's where you'd be testing.

Last edited by Uncle Dog; 08-23-2009 at 10:53 PM.
Reply With Quote
  #9 (permalink)  
Old 08-23-2009, 10:51 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 254
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Close a child page and refresh parent page

Just spotted it working. What's next?
Reply With Quote
  #10 (permalink)  
Old 08-23-2009, 11:15 PM
WebProWorld Pro
 
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 265
getmea RepRank 1
Default Re: Close a child page and refresh parent page

Sorry, U Dog...I was so excited that it worked that I wound up testing (in IE) every single pic and anchor. I've yet to test it in FF.

Yes, I found the discrepancy between productPreviewWindow/productPreviewWin/productpreviewwindow and corrected it.

What's next? Now I will implement in every single page which calls out to the Closer Look (sku2.php) page.

THANKS VERY MUCH FOR YOUR ASSISTANCE!!!!

Regards,
John
Reply With Quote
  #11 (permalink)  
Old 08-23-2009, 11:16 PM
WebProWorld Pro
 
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 265
getmea RepRank 1
Default Re: Close a child page and refresh parent page

Isn't it like 3:15 in the morning in Scotland???
Reply With Quote
  #12 (permalink)  
Old 08-23-2009, 11:17 PM
WebProWorld Pro
 
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 265
getmea RepRank 1
Default Re: Close a child page and refresh parent page

Quote:
Originally Posted by williamc View Post
Your way works as well. I just prefer ajax's background processing and no need of multiple output pages in the popup.
Hey, WilliamC...

Thanks for the tip.

Unfortunately, I am AJAX illiterate.

Someday, I'll pick up an Ajax for Dummies book and learn.

Regards,
John
Reply With Quote
  #13 (permalink)  
Old 08-24-2009, 09:57 AM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 254
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Close a child page and refresh parent page

getmea - yes my last post was at 2:51 am. Glad to have been of help.

You're not AJAX illiterate - it's basically a mish mash of web technologies usually revolving around JavaScript on the client ,which you obviously understand. Wikipedia describe it beautifully, warts and all - Ajax (programming) - Wikipedia, the free encyclopedia

I think there is a tendency to think of AJAX as a tool when it's actually a toolbox.
Reply With Quote
  #14 (permalink)  
Old 08-24-2009, 02:10 PM
DaveSawers's Avatar
WebProWorld Veteran
 
Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 492
DaveSawers RepRank 3DaveSawers RepRank 3
Default Re: Close a child page and refresh parent page

Whilst AJAX isn't perfect, it's biggest advantage is that you can go back to the server to do stuff and then refresh only part of the page.

Problem with doing a full refresh is the whole page disappears and rebuilds. This is both annoying for users and time consuming. I would always recommend using AJAX over refreshing a full screen. Just take the W3Schools AJAX primer and away you go. Nothing complicated to it at all. It shouldn't take you more than 15 minutes to do the tutorial and get your first AJAX thingy working.
__________________
Dynamic Software Development
www.activeminds.ca

Last edited by DaveSawers; 08-24-2009 at 02:13 PM.
Reply With Quote
  #15 (permalink)  
Old 08-24-2009, 08:05 PM
WebProWorld Pro
 
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 265
getmea RepRank 1
Default Re: Close a child page and refresh parent page

Good tip, Dave...I'll check out the Ajax Primer...

Thanks.
Reply With Quote
  #16 (permalink)  
Old 08-24-2009, 11:17 PM
smo smo is offline
WebProWorld Pro
 
Join Date: Jun 2004
Location: India
Posts: 188
smo RepRank 0
Default Re: Close a child page and refresh parent page

Refreshing parent main window from child small window
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page refresh and screenreader users issue Webnauts Accessibility and Usability Forum 2 05-03-2006 01:48 PM
preloading child movies into parent movie pbrollwitme Flash Discussion Forum 1 07-18-2005 03:16 AM
Refresh page automatically on arrival Milo Web Programming Discussion Forum 1 01-28-2005 07:33 PM
How do I force the page to refresh from the server? zwickes Web Programming Discussion Forum 2 11-21-2004 01:34 PM


All times are GMT -4. The time now is 04:43 AM.



Search Engine Optimization by vBSEO 3.3.0