473,383 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

submit confirmation with radio button selected

Hi,

I am trying to create a javascript that will display a confirmation
message when a user submits a form and has specifically selected
a particular radio button.

For example:

<form action="foo.cgi" method="post">
<input name="question1" type="radio" value="1">Value 1</input>
<input name="question1" type="radio" value="2">Value 2</input>
<input name="foo" type="submit">
</form>

Assuming the user selects the second radio button (Value 2), how would I
display a message that states "Are you sure you want to do value 2?" and
then also includes a "Submit" and "Cancel" button?

Any help would be much appreciated. Thx!

- JF
Jul 23 '05 #1
3 4004
<form action="foo.cgi" method="post"
onsubmit="return(!this.question1[1].checked || confirm('Are you sure you
want to do value 2?'))">

.... which says that if the second 'question1' radio button ISN'T checked
or the user HAS assented to the confirmation message, proceed.
Jul 23 '05 #2
jf*****@hotmail.com wrote:
Hi,

I am trying to create a javascript that will display a confirmation
message when a user submits a form and has specifically selected
a particular radio button.

For example:

<form action="foo.cgi" method="post">
<input name="question1" type="radio" value="1">Value 1</input>
<input name="question1" type="radio" value="2">Value 2</input>
<input name="foo" type="submit">
</form>

Assuming the user selects the second radio button (Value 2), how would I display a message that states "Are you sure you want to do value 2?" and then also includes a "Submit" and "Cancel" button?

Any help would be much appreciated. Thx!

- JF


Or...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<script type="text/javascript">

function chk()
{
return confirm('Are you sure you want to do value 2?');
}

</script>
</head>
<body>
<form action="foo.cgi" method="post">
<input name="question1" type="radio" value="1"
onclick="this.form.onsubmit=null" />Value 1
<br />
<input name="question1" type="radio" value="2"
onclick="this.form.onsubmit=chk" />Value 2
<br />
<br />
<input name="foo" type="submit">
</form>
</body>
</html>

<input> tags are singlets (no closing tag).

Jul 23 '05 #3
Way cool. Thank you both (Paul R & RobB) for the feedback.

- JF
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Carlo | last post by:
Hi I have three radio buttons where I need the user to select one of the buttons and its value must be emailed to me using the submit button. I'm using strBody = strBody & "<tr><td>Q1:" &...
2
by: jason | last post by:
The following (likely far from imperfect code), reports a value of NaN in the j4 display. I suppose the problem is I am not really passing the "checked" value of the radio button via .value ......
4
by: Sjon | last post by:
Here's A piece of my code: <form action="dimensions.php" method="POST"> <br><input type="radio" style="background : #84c7e8" name="categorie" value="Customer" checked> Customer</br> <br><input...
5
by: Samy | last post by:
Hi There, I have a label in a datagrid which I make it a input type = radio in ItemDataBound so that radio buttons are shown in the datagrid. This is how I have it... ASPX... <asp:Label...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
1
by: sam | last post by:
Hi All, I have a form with 4 checkboxes and 4 text boxes and one submit button. The form should work such a way when I select a particular checkbox and give a url in text box, the form should...
2
by: fliss | last post by:
Hello I have four submit buttons on my page - each carrying a value which refreshes the page selects from my db and displays the results in the drop down. The prob is i would like another...
1
by: arggg | last post by:
I created a submit form that calls a javascript:AjAX Command that will call the data and submit it without have the page refresh. This works perfect in Firefox however in IE and Opera when the...
1
by: ismailc | last post by:
Hi, I don't know xslt - i just need a modification done to existing xslt file. At the moment the page has 2 radio buttons with a submit button, which exeutes the code dependant on the radio...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.