Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 4.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-10-2009, 10:05 PM   PM User | #1
iced112233
New to the CF scene

 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
iced112233 is an unknown quantity at this point
Post Button submit and refresh page?

Hi.

I have 3 frames on my page and need the page to refresh after a submit button is pressed for its changes to take effect (change the style sheet)

However using
Code:
<input type="submit" onSubmit="window.location.reload();" value="Go">
just submits and does not refresh.



Does anyone know how to make it refresh as well?
iced112233 is offline   Reply With Quote
Old 06-10-2009, 10:35 PM   PM User | #2
arthurakay
Regular Coder

 
Join Date: Nov 2007
Location: Chicago
Posts: 134
Thanks: 2
Thanked 9 Times in 9 Posts
arthurakay is an unknown quantity at this point
Are you pointing the form's action attribute at the page you're reloading?

Code:
<form action="yourPage.php" ... />
You shouldn't even need to use JavaScript for something like this - submitting the form to the same page ought to do exactly what you want.
__________________
Arthur Kay
arthurakay is offline   Reply With Quote
Old 06-10-2009, 11:29 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,172
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
ONSUBMIT is not a valid event handler for a button of *ANY* kind.

(onsubmit is only valid in the <form> tag)

But...

But actually, it would be a disaster if your code *did* work. Because the reload of the page would take place *BEFORE* the submit occurred, and the form would *NOT* submit!!!

In any case, I'm with Arthurakay: Yes, submitting the <form> *WILL* refresh the page. Are you perhaps saying that the <form> is inside a <frame> or <iframe> and you want the *entire* page to refresh, not just that frame???

If that's the case, doing window.location.reload() won't help. That will only cause a refresh of the frame, which is going to happen anyway with the form submittal.

You could fix that. You could maybe do:
Code:
<form ... onsubmit="setTimeout('parent.location.reload()',500); return true;">
So the form submits and then a few milliseconds later the "parent" (the outer frameset or window) reloads.

BUT...

But now the form submittal will be *forgotten*!! The server will try to send back an HTTP Response to a window (a frame really is a window) that no longer exists!!
Old Pedant is offline   Reply With Quote
Old 06-11-2009, 02:33 PM   PM User | #4
iced112233
New to the CF scene

 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
iced112233 is an unknown quantity at this point
Yes the form is in a frame and I am wanting the whole page to refresh after the info has been submitted.

All the linked php page does is set a cookie when the form is sent, but the whole page needs to be refreshed for the cookie to take effect.

Thanks Old Pendant but the code didn't work, it just ignores it.

I am thinking placing JavaScript on the actual cookie.php its self. But not sure what to actually add to it.

Last edited by iced112233; 06-11-2009 at 02:41 PM..
iced112233 is offline   Reply With Quote
Reply

Bookmarks

Tags
button, javascript, refresh, submit

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 06:04 PM.


Advertisement
Log in to turn off these ads.