evr72 Posted October 4, 2012 Share Posted October 4, 2012 Hello, I am new at Javascript and trying to make this work. I have a button that I have called "Back To Main Page"I have the followin script onclick="if (confirm('Would You Like To Save Your Work?'))submit(); return false;" This works and it asks the user if he/she would like to save ther work if they click ok it saves if cancel noting happens up to this point is ok, but I would like to redirect the user to another page if the user clicks ok I have tried a few things but nothing seems to work. any help is much appreciated. thanks!! Link to comment Share on other sites More sharing options...
Ingolme Posted October 4, 2012 Share Posted October 4, 2012 The form submits to a particular page, you can choose which page by setting the action attribute of the <form> element. Link to comment Share on other sites More sharing options...
bittu4u4ever Posted October 5, 2012 Share Posted October 5, 2012 You can do as follows to acheive what you want. function submit() { //submit watever you want to submit//and if submit is successfull return true//else return false} function onBackClicked() { if(confirm("Would you like to save your work?")) {if(submit()) //when submit is successfull redirectwindow.location.url = "desired url of home page"; }elsereturn false;} onclick="onBackClicked();" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now