Page 1 of 1

If/Then for 2 Option Buttons?

Posted: Tue Jun 10, 2014 2:32 pm
by dandun
Hello

I am starting to become more familiar with LiveCode, but still very much a beginner stage. I am trying to accomplish what I assume is an if/then script for 2 separate option menus. I am not sure this is the east way to do this, so I am open to suggestions. I provided an example to explain what I am trying to do.
Scenario:

1. 2 option buttons, labeled “Food” and the other labeled “Type”
2. 1st Option button labeled “food”, has list of Fruit or vegetables
3. 2nd Option Button is “disabled” until a choice from the first option button is selected
4. If the “fruit” is selected from button 1, then option button 2 will display the fruit option list
5. If the “vegetable” option is selected from button 1, then the option button 2 will display the vegetables option list

Thank you again for your help
Dan

Re: If/Then for 2 Option Buttons?

Posted: Tue Jun 10, 2014 3:18 pm
by Simon
Hi Dan,
The option menu comes with switch/case which is very much like if/then.
I'm sure you've seen it by now:

Code: Select all

on menuPick pItemName
   switch pItemName
      
   end switch
end menuPick
pItemName will contain whatever is selected from the dropdown. Here is the first one:

Code: Select all

on menuPick pItemName
   switch pItemName
      case "Food"
disable button 2
break
case...
   end switch
end menuPick
To load button 2 you use

Code: Select all

set the text of button 2 to "Apple" & cr& "Pear"&cr...
Can you take it from there?

Simon

Re: If/Then for 2 Option Buttons?

Posted: Tue Jun 10, 2014 5:58 pm
by dandun
Thank you Simon. Perfect!