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.
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.
<input type="submit" name="commentButton" value="Submit Comment" onclick="alert('Your comments have been submitted. Thank you for your feedback.'); location.reload();">
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.
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
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.
# process the form data...
print "<p>Your comments have been submitted</p>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)