radio buttons - Multiple choice question
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 10
- Joined: Mon Oct 05, 2009 3:31 am
radio buttons - Multiple choice question
Hi All,
I'm completely new to RunRev, so please bear with me. what I'm trying to do is very simple, however I can't get it right.
I'm trying to create a 1 question multiple choice quiz for testing purposes, I'm using radio buttons with 4 possible choices. My question is, how do I refer in the script to the correct answer? here is my script.
on mouseUp
if button "firstone" is selected then
answer "Good"
else
answer "Wrong"
end if
end mouseUp
even when the correct choice is being selected, I still get the wrong answer.
what am I doing wrong?
Please advise, or point me to the right direction on working with radio buttons.
Thanks,
I'm completely new to RunRev, so please bear with me. what I'm trying to do is very simple, however I can't get it right.
I'm trying to create a 1 question multiple choice quiz for testing purposes, I'm using radio buttons with 4 possible choices. My question is, how do I refer in the script to the correct answer? here is my script.
on mouseUp
if button "firstone" is selected then
answer "Good"
else
answer "Wrong"
end if
end mouseUp
even when the correct choice is being selected, I still get the wrong answer.
what am I doing wrong?
Please advise, or point me to the right direction on working with radio buttons.
Thanks,
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
If you haven't done so already, group the four radio buttons. Then use the inspector palette to turn on the radigroupBehavior property of that group.
Now the engine will automatically handle the hiliting-only-one-option part. Next, lookup the following temrs in the rev dictionary: hilitedButton, hilitedButtonId, hilitedButtonName.
HTH,
Jan Schenkel.
Now the engine will automatically handle the hiliting-only-one-option part. Next, lookup the following temrs in the rev dictionary: hilitedButton, hilitedButtonId, hilitedButtonName.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Livecode Opensource Backer
- Posts: 10
- Joined: Mon Oct 05, 2009 3:31 am
Hi Janschenkel,
Thanks for your reply, based on the outcome I got by following your instructions, it looks like this option allows you to set the default value for a radio button. However, what I'm trying to achieve here is, to have the program to make the correct decision based on the user response.
for example:
if button "Radio1" of group "RadioGroup" is selected then
answer "Correct!"
else
answer "Wrong"
end if
Is this correct?
I apologize for my lack of knowledge, I'm coming from the python programing language, and the environment is totally different.
Thanks,
Thanks for your reply, based on the outcome I got by following your instructions, it looks like this option allows you to set the default value for a radio button. However, what I'm trying to achieve here is, to have the program to make the correct decision based on the user response.
for example:
if button "Radio1" of group "RadioGroup" is selected then
answer "Correct!"
else
answer "Wrong"
end if
Is this correct?
I apologize for my lack of knowledge, I'm coming from the python programing language, and the environment is totally different.
Thanks,
I use the hilitedbuttonname syntax but you can use hilitedbutton for the number of the button if needed.
Edit the script of the group that your buttons are in.
change the button number to the number of the correct button. you find the button number under size & position in the property inspector... this what you mean?
Edit the script of the group that your buttons are in.
Code: Select all
on mouseup
if the hilitedbuttonname of group "radiogroup" <> "thecorrectanswer" then
answer "Wrong"
else
answer "Right"
end if
end mouseup
Code: Select all
on mouseup
if the hilitedbutton of group "radiogroup" <> 1 then
answer "Wrong"
else
answer "Right"
end if
end mouseup
-
- Livecode Opensource Backer
- Posts: 10
- Joined: Mon Oct 05, 2009 3:31 am
the only book ive read is Software at the Speed of Thought by Dan Shafer. Its maybe a bit outdated but goes over the basics. You can actually download the examples in the book from runrev...
http://www.runrev.com/downloads/all-dow ... -examples/
http://www.runrev.com/downloads/all-dow ... -examples/
-
- Livecode Opensource Backer
- Posts: 10
- Joined: Mon Oct 05, 2009 3:31 am