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

Mutually exclusive checkboxes 1

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I'm relatively green :)-)) with HTML and need some help. I'm not exactly sure what the difference between a check box and radio button is (other then cosmetic). So, I am trying to set up a table that contains (among other things) three mutually exclusive checkboxes (for asthetic reasons) instead of radio buttons. I want to pass the value of the boxed checked in a 'POST'.

Assume the name of each box is row1_bx1, row1_bx2 and row1_bx3, etc. How do I set it up so each rowN set of boxes are mutually exclusive and a single identifier (row1_bxvalue) contains 1,2 or 3, depending on which of the 3 boxes is checked?
Code:
<tr>
   .
   .
   .
   <td width=&quot;58&quot;><INPUT type=checkbox name=row1_bx1 value=1
what else?>
Code:
</td>
   <td width=&quot;58&quot;>INPUT type=checkbox name=row1_bx2 value=2
and here>
Code:
</td>
   <td width=&quot;58&quot;>INPUT type=checkbox name=row1_bx3 value=3
here too>
Code:
</td>
   .
   .
   .
</tr>

Thanks.
 
OK, so a little more experimenting and I guess I have to use radio buttons for the mutually exclusive property. So the question changes to how do I modify the spacing and size of radio buttons? I cannot find any paramters to do this in the 'INPUT' tag documentation.

Thanks.
 
Never mind. I had a syntax problem with my <td> so that is why I thought something special had to be done for spacing on teh 'INPUT'. Sorry.
 
awingnut: I'm not exactly sure what the difference between a check box and radio button is (other then cosmetic).

The difference is function.

A checkbox is used when you want to decide YES/NO on an option. You might have fifty options, but each one is more-or-less an independent entity.

Use a radio button cluster when you want no-more-than-one item chosen from a group, where such choices are often mutually exclusive.

You would use a collection of checkboxes when designing a planet:

Will it have
[ ] Lakes
[ ] Rivers
[ ] Streams
[ ] Clouds
[ ] Volcanoes
[ ] George W. Bush
[ ] Childrens Television Programming

The planet might have none of these, or all of them, or any combination. Such a choice is ideally suited to check boxes.

However, consider the following choice:
Volcano #11285's status:
( ) Extinct
( ) Dormant
( ) Active

In this case, a volcano must be one of these things, but cannot be more than one. In this situation, a radio button cluster is the ideal tool.

So, deciding which control to use starts by deciding to look at what information you want to acquire and how best to ask your questions and how each acquisition tool lends itself to collecting different types of information.

In the case you've mentioned above, the functionality you want is a radio button cluster. Yes, you can figure out a way to make checkboxes (or text boxes, for that matter) operate in the same fashion as radio buttons, but the fact is, you're much better off using, well, radio buttons. That's what they're there for! [smile]

More than you asked, but I hope it helps.

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
As Edward noted near the end of his post, there really isn't a difference between the two, except in how they're scripted. If awingnut really wanted to, he could script a set of checkboxes to act like radio buttons (or vice-versa), but this would be bad (read: counterintuitive) user interface programming, so I don't recommend it. In fact, I strongly recommend against it. (Same goes for the rest of you kids; don't try this at home unless you're the only one who will be viewing the page. We have standards for a reason. Doing things &quot;just because you can&quot; is bad practice in Web design generally.)


JavaStripped
&quot;I did *not* escape. They gave me a day pass.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top