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!

Disabling Multiple Check Boxes

Status
Not open for further replies.

BLarche

Programmer
Nov 29, 2004
25
US
I am trying to create an application that allows me to disable check boxes based on a users selection of other check boxes. I have 7 different choices for a check box, and those 7 different choices can be ranked 1 - 3 ONLY once. So, for instance, of the 7 choices, you can only choose the choice once, and you must make three selections, ranked 1 - 3. I want to disable the check boxes for ranking 1 once a check box has been selected. In addition, I want to disable that check box in option 2 and 3 that has been selected in choice 1, etc.

Here is a depiction of what my form will look like:

Rank 1 2 3
Choice 1 [] [] []
Choice 2 [] [] []
Choice 3 [] [] []
Choice 4 [] [] []
Choice 5 [] [] []
Choice 6 [] [] []
Choice 7 [] [] []
 
One more thing to add... the check boxes will be created on the fly. The names will always change, but the suffix will always be "_1", "_2", and "_3". The names of the checkboxes will be something such as:

Column 1:
BSX_1
CAT_1
JOY_1
PFE_1

Column 2:
BSX_2
CAT_2
JOY_2
PFE_2

Column 3:
BSX_3
CAT_3
JOY_3
PFE_3
 
One more comment. If the check box is unchecked, I want ALL disabled checkboxes to be enabled once again, that includes ALL in the corresponding column and those in the other two or one columns.
 
Radio buttons would be much better suited for this, something like this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript"></script>
<style type="text/css"></style>
</head>
<body>
Choice 1
<input type="radio" name="rank1" value="choice1" />
<input type="radio" name="rank2" value="choice1" />
<input type="radio" name="rank3" value="choice1" />
<br />
Choice 2
<input type="radio" name="rank1" value="choice2" />
<input type="radio" name="rank2" value="choice2" />
<input type="radio" name="rank3" value="choice2" />
<br />
Choice 3
<input type="radio" name="rank1" value="choice3" />
<input type="radio" name="rank2" value="choice3" />
<input type="radio" name="rank3" value="choice3" />
<br />
Choice 4
<input type="radio" name="rank1" value="choice4" />
<input type="radio" name="rank2" value="choice4" />
<input type="radio" name="rank3" value="choice4" />
<br />
Choice 5
<input type="radio" name="rank1" value="choice5" />
<input type="radio" name="rank2" value="choice5" />
<input type="radio" name="rank3" value="choice5" />
</body>
</html>

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
There is a problem with that though. Once a selection has been made with a radio button, you can't uncheck it to enable the other form elements. So once you have made your selection for say "choice1", once you disable the choice1 fields, you cannot re-enable them. With a checkbox you can uncheck the selection and re-enable the checkboxes that were disabled based on that selection.
 
Using radio buttons wouldn't require you to disable anything. When you select a different choice for #1, it deselects your previous choice.

The only issue where this becomes a problem is if you selected #1 for choice 1 and then wanted to select #2 for choice 1. All you'd need to do in this instance is swap the values for whatever you had originally selected for #2.

For instance, you select #1 for choice 3. You then select #2 for choice 5. You then decide you want to change choice 5 to #1. When you click on #1 for choice 5, you go find what was previously selected as #1 (choice 3) and then set that to #2 (since that was the original value of choice 5 - it's like a 2 way radio button.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top