Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Using radio buttons to set the value of a text field

Avatar

Level 2

I have a set of three radio buttons on a form (a performance evaluation). If I select the "1" button, I want 1 to populate in the text field. The same goes for "2" and "3"

I have not been able to code the buttons correctly for this scenario, and can't figure out how to do it.

From a previous post, I was able to get check boxes to do what I want, but they won't really work because I can't set them so that only one back may be selected.

Can this be done?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 4

That looks right to me (assuming that the text field is called "WorkSkillsRating") when you select the code for any element that has nested elements (as with WorkSkillsButtons having WorkSkills1-3) the code for the selected event for each nested element is shown. you can ignore:

form1.Page2.WorkSkillsButtons.WorkSkills1::initialize - (FormCalc, client)

 

 

form1.Page2.WorkSkillsButtons.WorkSkills2::initialize - (FormCalc, client)

 

 

form1.Page2.WorkSkillsButtons.WorkSkills3::initialize - (FormCalc, client)

...because those are the placehoders for the initialize events of each radio button in the group.

The important part is:

form1.Page2.WorkSkillsButtons::initialize - (FormCalc, client)

WorkSkillsRating.rawValue = $.rawValue

make sure it's on the same line. the same should be done for the change event.

View solution in original post

0 Replies

Avatar

Level 4

I'm not sure if I understood your problem...

Is it just that you need to make sure that only one of the radio buttons are checked at any given time? If this is it, then it's as simple as making sure that all of the radio buttons are directly under the same radio button list in the form heirarchy. when they are all under the same radio button list, only one of them can be selected at a given time.

if you are having trouble making the text field have the value of the selected radio button, then put the following code under the 'initialize' and 'change' events of the radio button list (Make sure it's the list, not just one of the buttons inside if the list).

TextField1.rawValue = $.rawValue

If I didn't understand your question, or if you need more help, feel free to reply.

- Scott

Avatar

Level 2

Do I use both the initialize and the change events at the radio-button group level?

And, if I select the radio-button group, the individual buttons are listed underneath it in the script panel. Do I just ignore them and put the code with the radio-button group?

Avatar

Level 2

This is the code that gets inserted when I select the radio-button group and then select the initialize event:

form1.Page2.WorkSkillsButtons::initialize - (FormCalc, client)

WorkSkillsRating.rawValue

= $.rawValue

 

form1.Page2.WorkSkillsButtons.WorkSkills1::initialize - (FormCalc, client)

 

 

form1.Page2.WorkSkillsButtons.WorkSkills2::initialize - (FormCalc, client)

 

 

form1.Page2.WorkSkillsButtons.WorkSkills3::initialize - (FormCalc, client)

 

 

Avatar

Correct answer by
Level 4

That looks right to me (assuming that the text field is called "WorkSkillsRating") when you select the code for any element that has nested elements (as with WorkSkillsButtons having WorkSkills1-3) the code for the selected event for each nested element is shown. you can ignore:

form1.Page2.WorkSkillsButtons.WorkSkills1::initialize - (FormCalc, client)

 

 

form1.Page2.WorkSkillsButtons.WorkSkills2::initialize - (FormCalc, client)

 

 

form1.Page2.WorkSkillsButtons.WorkSkills3::initialize - (FormCalc, client)

...because those are the placehoders for the initialize events of each radio button in the group.

The important part is:

form1.Page2.WorkSkillsButtons::initialize - (FormCalc, client)

WorkSkillsRating.rawValue = $.rawValue

make sure it's on the same line. the same should be done for the change event.

Avatar

Level 2

All that works, but one thing has me stumped. Where is the information that tells me I need both of those events? I would never have thought of that in a million years.

Avatar

Level 4

The information for this specific case isn't anywhere. The best that you can do is understand what triggers each of the events, then ask yourself which of those triggers are pertinent to your current issue.

http://help.adobe.com/en_US/livecycle/es/LiveCycle_Designer_Scripting_Basics.pdf ...

The above link contains a great deal of information regarding how to use scripts within Livecycle Designer. The section that you would be most interested in in order to learn about the available events can be found under "Events >> List of Events".

You needed to use the initialize event so that the text field would be updated when the document was opened. This ensure that the text field has the value of the default radio button when it is opened for the first time.

You needed to use the change event so that, when the use selects a different radio button, the text field is updated with the new value.

That's about it. That PDF file that I link to above is a bit long, but it's a great place to get a good grasp of the basics of scripts.

If you have any further questions, feel free to ask. 😃 Have a good one.

- Scott