Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirm Submit 1

Status
Not open for further replies.

DVDGirl

Programmer
Mar 29, 2001
42
US
Hi -
I know this has been asked before, but when I tried others suggestions, they just didn't work for me...(though I'm probably just doing something wrong.)

I'm trying to confirm a submit in javascript. Basically, after clicking "submit", the user will get prompted to confirm the submission of the form. If they click "OK", take them to one page, if they click "Cancel" take them to another page.

Here is my code so far:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function confirmGo()
{
if(confirm('The data above will now be saved.\nClick OK to Save and Generate Reports, or Cancel to Exit'))
document.StaffDelivered.submit();
else
location.href=&quot;StaffDelivered.asp&quot;;
}
</SCRIPT>

<form name=&quot;StaffDelivered&quot; method=&quot;post&quot; action=&quot;StaffDelivered3.asp&quot;>
CODE...
...
...
<center><input type=&quot;submit&quot; value=&quot; Go &quot; onClick=&quot;confirmGo()&quot; name=&quot; submit&quot;>
</form>

Sorry if this looks really funky, but I'm a newbie at Javascript. Any help or suggestions are greatly appreciated!

-DVD Girl
 
I did something similar, but for mine, clicking cancel just makes the form &quot;not submit&quot; anything, and it stays on the same page.

Here's what i did:
--------------------------------
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function confirmGo()
{
return confirm('The data above will now be saved.\nClick OK to Save and Generate Reports, or Cancel to Exit');
}
</SCRIPT>

<form name=&quot;StaffDelivered&quot; method=&quot;post&quot; action=&quot;StaffDelivered3.asp&quot; onSubmit=&quot;return confirmGo();&quot;>
CODE...
...
...
<input type=&quot;submit&quot; value=&quot;Go&quot; name=&quot;submit&quot;>
<!--This does the cancel action and takes it to your cancel page //-->
<input type=&quot;button&quot; value=&quot;Cancel&quot; name=&quot;Cancel&quot; onClick=&quot;window.location.href='StaffDelivered.asp'&quot;;>

</form>

------------------------

Hope this helps...
 
Thank you, multiplex77! That worked perfectly! Thank you so much! I can't tell you how much I've been agonizing over this little thing! Giving this post a star! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top