Radio 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
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Radio buttons

Post by DavJans » Fri Apr 18, 2014 10:28 pm

I have almost finished a card that will set permission levels for users, I have everything that I want working but I cant find an example for this last step. Hopefully I can explain what i need easily enough.

I have 3 columns with 3 radio buttons each, they are grouped. the groups are tracker, report, and yard (Group yard has radio buttons names 0, 1 and 2) the radio button names are the same in each group

The info is stored in a mysql database and my user list shows up in a datagrid.

so far then I select user1 in the datagrid I get a variable that looks like this 1,1,1 if I select user2 I get 2,2,2
basically I'm getting the data from the mysql server comma delimited and each value is the name of the radio button (levels of access)

what I would like is that when I select a different use in the data grid and get the variable I want to somehow translate that into the correct radio button getting automatically selected.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Radio buttons

Post by magice » Fri Apr 18, 2014 10:47 pm

put each of the 3 numbers in separate variables

then name the radio buttons with a name then numbers 1-10. something like yard1, yard2, yard3 etc.then try this in the script

Code: Select all

 do "set the hilite of btn yard"&yourVariable&" to true"
now i am sure that there is a way to do it without the do command, but I always get compilation errors and this is my way of cheating.

DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Radio buttons

Post by DavJans » Fri Apr 18, 2014 11:00 pm

[quote="magice"]put each of the 3 numbers in separate variables

then name the radio buttons with a name then numbers 1-10. something like yard1, yard2, yard3 etc.then try this in the script

Code: Select all

 do "set the hilite of btn yard"&yourVariable&" to true"
is it possible to do something like this?

Code: Select all

 do "set the hilite of btn"&yourVariable&" in group yard to true"
and not rename the radios?
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Radio buttons

Post by magice » Sat Apr 19, 2014 12:24 am

DavJans wrote: is it possible to do something like this?

Code: Select all

 do "set the hilite of btn"&yourVariable&" in group yard to true"
and not rename the radios?
Actually, yes. You are close.

Code: Select all

do "set the hilite of btn "&yourVariable&" of group yard to true"
be aware though, that the number of each button is determined by its order of creation (or the order of the id number). For that reason I like to reference buttons by name, but then I am a control freak.
In fact, I think you can eliminate the do command and just say

Code: Select all

set the hilite of btn yourVariable of group yard to true

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Radio buttons

Post by [-hh] » Sat Apr 19, 2014 2:49 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 1:08 pm, edited 1 time in total.
shiftLock happens

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Radio buttons

Post by Klaus » Sat Apr 19, 2014 1:10 pm

Hi friends,

a general hint: Do not name any objects with a NUMBER!
That is asking for trouble and even RunRev advises against it!


Best

Klaus

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Radio buttons

Post by atout66 » Sat Apr 19, 2014 1:18 pm

Hey Klaus, do you mean I should avoid to name btt like this:
myBtt1
myBtt2
myBtt3
and so on...
:?:
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Radio buttons

Post by Klaus » Sat Apr 19, 2014 1:34 pm

No, I mean "pure" numbers like:
0
1
2
3
etc. :D

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Radio buttons

Post by [-hh] » Sat Apr 19, 2014 1:38 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 1:08 pm, edited 2 times in total.
shiftLock happens

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Radio buttons

Post by atout66 » Sat Apr 19, 2014 1:40 pm

Ah, I prefer, you scared me! (to Klaus)
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Radio buttons

Post by Klaus » Sat Apr 19, 2014 2:02 pm

@atout66
Sorry for that :D

@Herrmann
Exactly!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Radio buttons

Post by jacque » Sat Apr 19, 2014 5:45 pm

For radio groups, also see the hilitedButtonName and the hilitedButton.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Radio buttons

Post by DavJans » Mon Apr 21, 2014 4:04 pm

Really good information from all of you, Thank you. I will rename my buttons as to not use numbers only.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

Post Reply