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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using checkboxes as radio buttons

Status
Not open for further replies.

gdowns

Programmer
Sep 22, 2002
2
US
I have a multirow table with two checkboxes in each row. For each row I need the checkboxes to act like radio buttons, if one is checked the other becomes unchecked.

<tr><td><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;away&quot; VALUE=&quot;1&quot;></td>
<td>New York Jets</td>
<td>New York Giants</td>
<td><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;home&quot; VALUE=&quot;2&quot;></td></tr>

I think I need to add &quot;onclick=&quot; to the checkboxes and a Sub or Function to call but I don't know the syntax for the checkbox or the Sub. Can someone help? Thanks.
 
Why not use radio buttons? Name each pair according to &quot;game&quot; and a counter?

If you name them home and away you are going to receive a comma-delimited array of values for Request.Form(&quot;home&quot;) and Request.Form(&quot;away&quot;) that you will not be able to do anything beyond total because there will be no way to tell which check lines up with which game. Also, if they are all named the same you will not be able to consistently uncheck a paired box because the javascript will set up all checkboxes with the name &quot;home&quot; as an array and all checkboxes named &quot;away&quot; as an array. You will need to get the index for the box that has fired the onClick event and then apply it to the array that holds the opoosite boxes and set the checked attribute of the box to false.

If you want to post a little more code we may be able to help you create a more efficient procedure.
-Tarwn &quot;The problem with a kludge is eventually you're going to have to back and do it right.&quot; - Programmers Saying (The Wiz Biz - Rick Cook)
&quot;Your a geek!&quot; - My Girlfriends saying
 
I would like to use radio buttons but I would have up to 16 rows in the table (8 pairs of teams) and I thoughtI could only have 1 radio button selected on the whole page. Is that not correct?
 
1 radio button is select per name.. so if you name each row of radio buttons a different name, then it will be how you want it.. I would name then each the record number.. 1, 2, 3 etc.. then on the next page you can do a loop till how many records were displayed..


For i=1 to totalrecords
Response.Write Request.Form(i) & &quot;<br>&quot;
next www.vzio.com
ASP WEB DEVELOPMENT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top