Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How can I refer to individual Radio Buttons that belong to different groups?

Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Hi everyone!!

 

I need the user to select two Radio Buttons, each one in a group, before a dialog box pops up.

I know how to select and trigger actions from Radio Buttons in the same group, but how can I

do that when they are in different groups? 

 

Thanks a lot for your help!!

TOPICS
Create PDFs, How to, JavaScript, PDF forms

Views

1.6K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , May 12, 2021 May 12, 2021
You call dialog box from radio buttons action and you want to call it when combination of two of them are checked? lets say you have "Group1" and "Group2" both group with  choices of "Choice1" and "Choice2" and lets say you want to call dialog box only if both "Choice1" are selected, as Mouse up event of both buttons you can use something like this: if(this.getField("Group1").value == "Choice1" && this.getField("Group2").value == "Choice1") //code for dialog box goes here

Likes

Translate

Translate
Adobe Community Professional ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

I would use the calculation event of a (hidden) text field to do it.

You can check the values of both groups, and if the two values you're interested in are selected then show the dialog.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Really? I cannot access the values of the radio buttons individually? Well, thanks a lot for the information, but can you show me what the code for this instruction would look like? I never used the calculation event before.

 

Thans a lot for your help.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Radio-buttons don't have an individual value, only the group does. They have export values, which is the value that the group has if they are selected. It's the same for check-boxes, although there you can have a group with just a single widget, which is not usually done with radio-buttons (although it is possible).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

OK. Thanks a lot!

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

If I replace the radio buttons for checkboxes, would it be possible to access them individually?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

You call dialog box from radio buttons action and you want to call it when combination of two of them are checked?

lets say you have "Group1" and "Group2" both group with  choices of "Choice1" and "Choice2" and lets say you want to call dialog box only if both "Choice1" are selected, as Mouse up event of both buttons you can use something like this:

if(this.getField("Group1").value == "Choice1" && this.getField("Group2").value == "Choice1")
//code for dialog box goes here

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Thanks a lot for your help, Ms. Nurani!

It was really helpful, as usual.

Cheers!

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

Hi ms Nurani,

 

Now I have a new problem: I´m trying to create two more scripts that will make a dialog box pops up, in case the

answers are wrong. However, the dialog box appears before I have selected the two radio buttons. It opens up just after I have selected the first radio button. Below is the script:

 

if(this.getField("Group2").value == "Choice1" && this.getField("Group3").value == "Choice10")
{
app.alert("Correct answer. Congratulations!", 3,0);
}


else if(this.getField("Group2").value !== "Choice1" && this.getField("Group3").value == "Choice10")
{
app.alert ("Wrong answer. Try again.");.
}


else if(this.getField("Group2").value == "Choice1" && this.getField("Group3").value !== "Choice10")
{
app.alert("Wrong answer. Try again.");
}

 

 

Thanks a lot again for your help!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

Where have you placed the script?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

That is because you set your condition that way.In your script 2nd condition will give alert if you click "Group3" Choice10 and in 3rd condition if you click "Group2" Choice1. So for example if you want select buttons from both groups to activate condition but you also don't want to be specific "Choice" you need to set condition to check if group is checked,something like this:

if(this.getField("Group2").value == "Choice1" && this.getField("Group3").value == "Choice10")
{
app.alert("Correct answer. Congratulations!", 3,0);
}


else if((this.getField("Group2").value !== "Choice1" && this.getField("Group2").value != "Off") && this.getField("Group3").value == "Choice10")
{
app.alert ("Wrong answer. Try again.");
}


else if(this.getField("Group2").value == "Choice1" && (this.getField("Group3").value !== "Choice10" && this.getField("Group3").value != "Off") )
{
app.alert("Wrong answer. Try again.");
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

Thanks a lot Ms. Nurani. I tested your code and it´s working partially.

So far, I have inserted the code in the Mouse Up sections of "Group2Choice1" and "Group3Choice10" only.

When I select "Group2Choice1" and then "Group3Choice10", I get the "Congratulations" message.

If I invert the order of the selection I also get the message.

But I still have the following problem:

 

    If I select any other choice in Group2 and THEN select "Group3Choice10", I get an error message.

 but

    If I select "Group3Choice10" FIRST and then any other choice in Group2, no message pops up.

    

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

Thats because code only work when you click on radio button that have code as mouse up event,if radio button don't have code then it won't work. If you want your code to work "automatically" put it into text field as "Custom calculation script" then you don't need to put codes in radio buttons.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

LATEST

Thanks for your help. You´re right. I forgot to insert the code in the other Mouse Up events. 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines