Forum Moderators: open
<input type="submit" value="Update Project" onclick="redirect()"/>
And the Javascript is as follows:
<SCRIPT language="JavaScript">
function redirect() {
window.location = 'EditProjects.php';
}
</SCRIPT>
The form submits but does not take the user to the previous page as instructed in the javascript. Does anyone have any ideas?
Thanks in advance
In your form, when the user clicks the submit button, the onclick event will be fired, calling your redirect function. The redirect will set the window.location value. However, your other events (onsubmit) are probably still being processed. So after it sets the window.location, the form will submit sending you to the form processing page instead. You could prevent the form from submitting by having your onclick return false. For example:
<input type="submit" value="Update Project" onclick="redirect();return false;"/>
But then your form wont submit.
Instead, you need to handle this server side. When the form submits, have the form processing page do the redirect.