Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Regular Coder
    Join Date
    Nov 2007
    Location
    Chicago
    Posts
    134
    Thanks
    2
    Thanked 9 Times in 9 Posts
    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.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    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!!

  • #4
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •