I have a HTML form which, when submitted I want a popup to appear saying 'Are you sure you wish to submit?', with yes and no options. The yes will contnue submitting the form, and the no will do nothing at all but close the popup.
Bear in mind i'm not a programmer :) |
Give this a try - you can't have yes / no unless you use VBscript, then it wont work in Netscape etc. You can have OK / Cancel option though:
Add this javascript to your page: <script language="JavaScript"> <!-- function submitForm(formName) { if(confirm("Are you sure you wish to submit?")) { document.forms[formName].submit(); } } //--> </script> Then your submit button for your form would be: <input type="button" name="submitButton" value="Submit" onclick="javascript:submitForm('myForm')"> Change myForm to the name of your form, and make sure the button type is "button" and not "submit" |
That's great. Cheers :)
|
:( everything works except when you actually click OK, the form doesn't submit. Nothing happens.
The VBScript version would be better as we only use IE. Could you convert the code?? Cheeky - i'm sorry. :rolleyes: |
<html>
<head> </head> <body> <form method="GET" action="rusure.htm" onsubmit="return checkForm()"> Your name : <input type="text" name="myname" /> <br> <input type="submit" value="Submit Form" /> </form> <script language="VBScript"> function checkForm() if msgbox("Are you sure you wish to submit?",vbYesNo,"Submit Form?") = vbYes then checkForm=true else checkForm=false end if end function </script> </body> </html> [Edited by SCOSaltire - 1/24/2003 9:16:35 PM] [Edited by SCOSaltire - 1/24/2003 9:26:49 PM] |
You got there in the end :)
Thank you :D:D:D - life saver. |
lol
problem was how to make the important bits bold :rolleyes: glad to be of help :D |
All times are GMT +1. The time now is 04:44 PM. |
© 2024 MH Sub I, LLC dba Internet Brands