ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   HTML form confirmation??? (https://www.scoobynet.com/computer-and-technology-related-34/170789-html-form-confirmation.html)

rik1471 24 January 2003 02:29 PM

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 :)

legacyPete 24 January 2003 03:11 PM

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"

rik1471 24 January 2003 04:25 PM

That's great. Cheers :)

rik1471 24 January 2003 04:31 PM

:( 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:

SCOSaltire 24 January 2003 09:14 PM

<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]

rik1471 24 January 2003 09:32 PM

You got there in the end :)

Thank you :D:D:D - life saver.

SCOSaltire 24 January 2003 10:21 PM

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