Forum Discussion
Set variable to object contents?
I've got a set of four radio buttons each with long(ish) content. e.g.,:
- Lorem ipsum dolor sit amet, consectetuer elit.
- Maecenas porttitor congue massa a tellus.
- Purus lectus malesuada libero, sit amet.
- Nunc viverra imperdiet enim. Fusce est.
When the user clicks on one of the radio buttons, I want to set a variable (e.g., var01) to the value of that button's content.
So, for example, if the user clicks on radio button 2, the variable would be set to "Maecenas porttitor congue massa a tellus."
I can do this by setting the variable to the value, of course:
set var01 to value Maecenas porttitor congue massa a tellus.
But the finished course will have 160 or so radio buttons, and it would be MUCH easier if I could do something like the following:
set var01 to value radio_02.text
Is this possible? I've scoured these forums for an answer, but wasn't able to find one. (It's entirely possible that I missed it, though, so apologies if so.)
Thanks
Christien
- WaltHamiltonSuper Hero
You have to enter that text sometime. Where ever it is, It shows and fits its text box, or whatever container it's in. Try entering it in a variable the first time, and put the variable reference (%radio_01.text%) in both the radio button, and trigger.
- ChristienLeeCommunity Member
Thanks, Walt.
That would boost my variable count into the low hundreds, which I'd prefer to avoid (not least because SL's variable creation and editing approach is a bit clunky), but it would definitely be easier than entering the value each time.
Still, if it were possible to reference the .text value of an object directly, that would be good to know going forward. Anyone?
Thanks again. - WaltHamiltonSuper Hero
Odds are, you could do it in javascript. The drawback is that js would have to use a variable to pass it back. You might be able to arrange a method of using just one variable to pass it back - (on click execute js and on click set variable to passbackvariable).