PDA

View Full Version : checking multiple checkboxes


Grayth
10-24-2005, 12:24 PM
Hey everyone,

I'm trying to figure out a nice clean way to run an if statement for multiple checkboxes.
In my window form the user can select 3 three different checkboxes.

the problem is this can create an error as while I want to give the user the ability to choose between the 3, only 1 can be selected. So I'm trying to figure out an if statement that says

something like

if more than 1 checkbox is selected
error" you can only select 1 checkbox";

thanks,
Troy

Stucky
10-24-2005, 01:48 PM
I think if you use the command checkBoxGrp instead of checkBox, you will get what you want, instead of creating a complicated if statement.



-S

mhovland
10-24-2005, 04:23 PM
Another trick I've used was to have the checkbox's change command disable (unselect) the other checkboxes. This only works if you are checking the state of the boxes in a separate proc. Code follows...


window -t "testWindow" testWin;
columnLayout;
checkBox -l "CheckOne" -cc "checkBox -e -v 0 chktwo; checkBox -e -v 0 chkthree" chkone;
checkBox -l "CheckTwo" -cc "checkBox -e -v 0 chkone; checkBox -e -v 0 chkthree" chktwo;
checkBox -l "CheckOne" -cc "checkBox -e -v 0 chkone; checkBox -e -v 0 chktwo" chkthree;
showWindow testWin;

Grayth
10-25-2005, 02:04 AM
I landed up taking a cheap route.

I just created a new string by adding the values from the other checkboxes. Since the value is either a 1 or 0 and I only had 3 checkboxes I just had to check for 4 values

111
110
011
101

It's cheap I know but as a newbie to Mel I tried to find a work around based on my abilities.

CGTalk Moderation
10-25-2005, 02:04 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.