If/Then for 2 Option Buttons?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
dandun
Posts: 24
Joined: Thu Apr 10, 2014 3:41 pm

If/Then for 2 Option Buttons?

Post by dandun » Tue Jun 10, 2014 2:32 pm

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
Attachments
if then drop down buttons.GIF

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: If/Then for 2 Option Buttons?

Post by Simon » Tue Jun 10, 2014 3:18 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dandun
Posts: 24
Joined: Thu Apr 10, 2014 3:41 pm

Re: If/Then for 2 Option Buttons?

Post by dandun » Tue Jun 10, 2014 5:58 pm

Thank you Simon. Perfect!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”