Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button submit value?

Status
Not open for further replies.

vlree

IS-IT--Management
Jan 16, 2004
31
0
0
US
I am new to ASP so I guess I am back with the dumbest of questions.

I have a form with 2 choices which are radio buttons...based on which radio button is chosen I want to redirect the user and pass some values to another page.

It seems with the radio button I can get one or the other to work, but not both.
I am doing it like this:
<input name="select" type="radio" value="singlebooth.asp" />

But i want to also pass some values entered else where in the form. Some other text boxes?

Thanks, have a good laugh! Victoria
 
There are many ways to do this - here's one.

Code:
<input name="[b]selectRadio[/b]" type="radio" value="singlebooth.asp" [b]onCLick="document.formName.action='singlebooth.asp'"[/b]>
<input name="[b]selectRadio[/b]" type="radio" value="doublebooth.asp" [b]onCLick="document.formName.action='doublebooth.asp'"[/b]>

you can also use server.transfer on the form handler page...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Have an onsubmit in the form tag and change the form's action:

<script>
function redirx() {
if (document.Form1.select[0].checked == true) document.Form1.action = document.Form1.select[0].value;
if (document.Form1.select[1].checked == true) document.Form1.action = document.Form1.select[1].value;
document.Form1.submit();
}
</script>

<form name=Form1 method=post onSubmit="return redirx()">
<input name="select" type="radio" value="singlebooth.asp" />
<input name="select" type="radio" value="doublebooth.asp" />
<input type="submit">
</form>
 
If your going to use mbiro's example, remove the document.Form1.submit(); line or you will get some wierd double post issues when the form submits twice. You should also explicitly return a true value rather then rely ont he browsr to pick a value for you:
Code:
<script language="javascript" type="text/javascript">
function redirx() {
if (document.Form1.select[0].checked == true) document.Form1.action = document.Form1.select[0].value;
if (document.Form1.select[1].checked == true) document.Form1.action = document.Form1.select[1].value;
//document.Form1.submit();
return true;
}
</script>

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top