submit confirmation with radio button selected

J

jforena

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
 
R

RobB

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top