choosing TWO selections

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
TheBigDuck
Posts: 23
Joined: Tue Nov 11, 2008 5:52 pm
Contact:

choosing TWO selections

Post by TheBigDuck » Fri Jan 09, 2009 9:37 pm

I am creating drop down menu that (for this example) has a list of all countries that MANUFACTURE CARS (again, this is an example)

SWEDEN
GERMANY
USA
ITALY

So if they choose GERMANY

I create the buttons AUDI, VW, Porsche, Mercedes in group AUTO

Code: Select all

create group "AUTO"
set the radiobehavior of group "AUTO" to false
    
    create button "Audi" in group "AUTO"
    set the style of it to radiobutton
repeat the other three...

Now the user has four radiobuttons (or checkboxes, doesn't matter).

I want the user to be able to choose MORE THAN ONE and then take action based on the choices

so if they choose "Audi" AND "Porsche", I can say,

"congrats, we are sending you a new Audi"

"congrats, we are sending you a new Porsche"

How do I do this?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Jan 09, 2009 11:50 pm

Dear TheBigDuck,

You should use checkboxes. Yes, it does matter! The user doesn't expect to be able to activate more than one radio button and, as you have noticed, you need to fiddle with the radiobehavior if you use radio buttons.

To find out which checkboxes are hilited, use a repeat loop that checks the hilite of each checkbox.

Code: Select all

repeat with x = 1 to number of buttons of grp "Cars"
  if the style of btn x is "checkbox" and the hilite of btn x then
    put the id of btn x & cr after myList
  end if
end repeat
delete last char of myList -- most of the time optional
-- do something with myList here
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply