Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

HTML form confirmation???

Thread Tools
 
Search this Thread
 
Old 24 January 2003, 02:29 PM
  #1  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Question

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
Old 24 January 2003, 03:11 PM
  #2  
legacyPete
Scooby Regular
 
legacyPete's Avatar
 
Join Date: Dec 2001
Posts: 202
Likes: 0
Received 0 Likes on 0 Posts
Post

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"
Old 24 January 2003, 04:25 PM
  #3  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

That's great. Cheers
Old 24 January 2003, 04:31 PM
  #4  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 24 January 2003, 09:14 PM
  #5  
SCOSaltire
Scooby Regular
 
SCOSaltire's Avatar
 
Join Date: Mar 2001
Posts: 1,809
Likes: 0
Received 0 Likes on 0 Posts
Talking

<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]
Old 24 January 2003, 09:32 PM
  #6  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

You got there in the end

Thank you - life saver.
Old 24 January 2003, 10:21 PM
  #7  
SCOSaltire
Scooby Regular
 
SCOSaltire's Avatar
 
Join Date: Mar 2001
Posts: 1,809
Likes: 0
Received 0 Likes on 0 Posts
Talking

lol
problem was how to make the important bits bold

glad to be of help
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Frizzle-Dee
Essex Subaru Owners Club
13
09 March 2019 07:35 PM
shorty87
Full Cars Breaking For Spares
19
22 December 2015 11:59 AM
Frizzle-Dee
Essex Subaru Owners Club
13
01 December 2015 09:37 AM
Pro-Line Motorsport
Car Parts For Sale
2
29 September 2015 07:36 PM
shorty87
Wheels And Tyres For Sale
0
29 September 2015 02:18 PM



Quick Reply: HTML form confirmation???



All times are GMT +1. The time now is 09:16 PM.