Expand my Community achievements bar.

SOLVED

How to get caption of selected radio button?

Avatar

Level 2

I'm building a dynamic form using javascript in Adobe livecycle designer X.  I have a radio button group, optGroup, with several individual option buttons. Later in the form, I want to refer to the selection that the user made with the caption of that selected button in the option group.  I've tried using resolveNode(optGroup.selectedMember().name+".caption.value.#text").value  but this works only if the first button in the group is selected.  Otherwise, selectedMember seems to be null and the code doesn't work.  Any ideas?

Thanks for your help!

BigO

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You can achieve this. I just thought that it would be easier to deselect the "specify values".

On the basis that you have a unique name for the radio button exclusion group, then this should work:

this.rawValue = RadioButtonList.selectedMember().caption.value.text.value; 

Hope that helps,

Niall

View solution in original post

12 Replies

Avatar

Level 10

Hi,

If you select the radio button exclusion group and go to the Object > Bindling palette. There you can deselect the "Specify values" checkbox and the .rawValue of the radio buttons will be the same as the captions.

Therefore you would not need to resolveNodes, just access the .rawValue of the radio button exclusion group.

this.rawValue = myRadioButtons.rawValue; 

Hope that helps,

Niall

Avatar

Level 2

Thanks Niall - i'll give that a try as a workaround.  Still, I would think that reading the caption of the selected radio button would be a simple task and figured I was just missing something, being new to this and all. So, kinda surprised someone hasn't hit me over the head with an obvious answer yet.  Again, thanks for your idea, I'll try it today and post back my result.

Avatar

Correct answer by
Level 10

Hi,

You can achieve this. I just thought that it would be easier to deselect the "specify values".

On the basis that you have a unique name for the radio button exclusion group, then this should work:

this.rawValue = RadioButtonList.selectedMember().caption.value.text.value; 

Hope that helps,

Niall

Avatar

Level 2

Niall  - when I originally built the radio button group, the individual buttons were separate.  Designer didn't automatically put them all in the same group.  So, at that time I had to select them all and "wrap in new radio button group".   I couldn't get your solution to work on that radio button group.  I would get the message that 'value' wasn't a property of 'text' (or vice-versa, can't remember which...) but it would work if the selected member was the first radio button in the group.  So, in frustration, i deleted that group and started a new one.  Designer automatically adds the radio buttons to the same button group as long as they are added one after the other.  After this, your solution worked on this group!  Thanks for your help.

Avatar

Level 10

Hi,

I suspect that the problem was that all of the individually created radio buttons had the same specified value. When you then grouped them in a single exclusion group this would cause a problem.

When you have a single radio button on the page, there are a couple of ways of copying it:

  1. I click it, hold down Control and drag, but keep within the group (you will see corner markers). Then release. This will create a new radio button that you can then position.
  2. Select the radio button and from the Edit menu go to Copy multiple times.

Glad you have it sorted,

Niall

Avatar

Level 2

The individual buttons all had the same value originally, but I changed them when I saw the little red plus sign indicating that there's a problem with the group.

When I was having the problem with the captions, the values were all unique.  Thanks for the tip on copying/creating radio buttons.  I had actually copied them from another form where they weren't part of a group.  thanks again for your help!

after thought: you know, another thought just occurred...these buttons were originally check boxes and I changed the "Type" to radio button which gave me all the individual buttons...then, I merged into a group...so i suspect some combination of these actions caused me my grief.

Avatar

Level 2

I've created a simple form with radio buttons that reproduce this issue.  How can I attach/upload this PDF with a message on this forum?

Avatar

Level 10

Hi,

If you upload the form to a file sharing site like Acrobat.com and then post the published link here:

Acrobat.com publish.png

Niall

Avatar

Level 2

Good stuff - thanks.

Here's the link https://acrobat.com/#d=OFcwLKJjS0wJ4TumuiwrpQ to a simple test form that re-produces this problem. There are two exclusion groups. The one on the left works fine - the javascript method attached to the change event is able to get the caption text.  But the one on the right has the same code, same everything (as far as I can tell), yet I get an error msg.  The only difference is that I converted check boxes into radio buttons.

Avatar

Level 7

So, I got your script to work by playing with the captions--I believe that you must have unintentionaly pasted a bad character into the "fthird option". I removed all the "f"'s and it worked. I went back and removed the  "f"'s individually, testing after each one, and found the fthird option to be the culprit.

Weird, I know--but it works now for me after doing that..

Best,

Stephen

Avatar

Level 2

Stephen,

thanks for taking the time to look at it.  You're right, I played with the captions and it worked for me too.  "Weird" is right!

Avatar

Level 7

Also, not sure why you are using this.parent as part of your reference to the text field. All the objects are siblings, so this.parent is superfluous. You'll see that if you remove it, the script still works.

Stephen