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!

Grouping Radio Buttons

Status
Not open for further replies.

ADEMAR

Programmer
Apr 20, 2002
43
0
0
US
Please help. I need to have the user select 1 and only 1 radio button out of 3 upon submit of form. How can I accopmlish this. Some code I could merge in would be nice.

Thanks in advance,
Adam D.
 
Give them all the same name. This will allow only one selection.

<input type=&quot;radio&quot; name=&quot;choose_me&quot;>
<input type=&quot;radio&quot; name=&quot;choose_me&quot;> DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Great, that should work, but how could I make the form not submit if no item has been selected? I need the user to selected an item before being able to submit the form.
 
One other thing as well, the code you gave above does indeed work but how can I tell once the form has been emailed to me what selection they choose. They all have the same name (choose_me).

Thannks for your help..Adam
 
To figure out which one is selected give them a unique value:
<input type=&quot;radio&quot; name=&quot;choose_me&quot; value=&quot;1&quot; selected>
<input type=&quot;radio&quot; name=&quot;choose_me&quot; value=&quot;2&quot;>

Add the selected key to one to be choosen by default (it might be checked rather than selected).

Otherwise if you want none selected to start you will need javascript to verify if one was choosen onSubmit DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
ok, so I added the value to my code but when I receive the email it doesn't say which button is selected.

CODE LOOKS LIKE -->
<input type=&quot;radio&quot; name=&quot;YouthLeague&quot; value=&quot;Mites&quot;>
<input type=&quot;radio&quot; name=&quot;YouthLeague&quot; value=&quot;Squirts&quot;>
<input type=&quot;radio&quot; name=&quot;YouthLeague&quot; value=&quot;PeeWee&quot;>
<input type=&quot;radio&quot; name=&quot;YouthLeague&quot; value=&quot;Bantams&quot;>

Email looks like this --> YouthLeague: ON
 
I tested it and it works fine. I get the value returned. Please paste the whole code. I bet frontpage is adding the value of on somewhere in the code. DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top