www.webdeveloper.com
Results 1 to 2 of 2

Thread: refresh browser

  1. #1
    Join Date
    Mar 2009
    Posts
    61

    refresh browser

    I have a cgi web page that displays some info and then has a form on the bottom for you to comment on that info.

    The problem I'm having is that after the user submits a comment from that form, the browser displays a whole new web page. What I want it to do is refresh the page the user is on (the one with the form on it) and display some sort of message all on that same page. Either by having the message displayed somewhere on the form page itself or by having a popup window come up.

    I've tried doing it with javascript:
    Code:
    <input type="submit" name="commentButton" value="Submit Comment" onclick="alert('Your comments have been submitted. Thank you for your feedback.'); location.reload();">
    But the onclick happens before the submit, so refreshing the page there doesn't really work - it doesn't show the new info. And after hitting submit I just get a blank web page.

    Is there any way to do this within my perl script instead, after it does all the form processing?
    Last edited by yssirhc; 05-05-2009 at 10:21 AM.

  2. #2
    Join Date
    Oct 2007
    Location
    Vienna, Austria
    Posts
    392
    The action attribute of the form says where the browser will send the data and it's also the page that gets loaded. Simply put all you need into this page -- i.e. the script for processing the form data could look like
    Code:
    # process the form data...
    print "<p>Your comments have been submitted</p>
    <p><a href=\"...\">continue</a></p>";
    Another way around is to send the form with AJAX. Then the page won't get reloaded and you have full control of what to do next.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles