Skip to main content
rakeshk21205956
Inspiring
January 11, 2017
Answered

I have two sets of Radio button Group0 and Group4 .. i want to hide and change username(tooltip) of group4 when Group0 is checked / unchecked

  • January 11, 2017
  • 1 reply
  • 1224 views

I have two sets of Radio button : Group0  and Group4 ..... I want to make Group4 readonly and change username(tooltip) when group0 is not choosed...... and when Group0 is choosed then the Group4 is not readonly and changes to other username (tooltip).

I used the following javascript in Group0 :

var f = this.getField("Group4");
if (event.target.value=="Choice1") {
  f
.display = display.visible;

  f.userName = "Please choose one of quantity";
} else {
  f
.display = display.hidden;

  f.userName = "";
  f
.setFocus();
}

It does the first condition but when i reset the Group0   Group 4 doesnot change to the second condition.

Please help

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

how., there is no calculation script in the radio fields?


Correct, there is no calculations script for a radio button or a radio button group. That is the reason why you need to create a separate text field and use the calculation field in that text field (which you hide from the user so that they cannot interact with it by making it hidden and read-only). Because you are no longer calculating the current field, you can no longer use the "event.target" property, you will have to get a reference to both radio button groups (g0 and g4).

1 reply

Karl Heinz  Kremer
Community Expert
Community Expert
January 11, 2017

I assume you are using this script as a "mouse up" action in one (or more) or the buttons of your radio button group. The problem with that is that these are only triggered when there is an actual mouse event. When you reset your form, none of your event handlers get called, so that's why this is not working. For things like this, I like to use a hidden and read-only text field that is only used to trigger a calculation script when the form changes. You can then use the following script to modify the behavior of your Group4:

var g0 = this.getField("Group0");

var g4 = this.getField("Group4");

if (g0.value=="Choice1") {

  g4.display = display.visible;

  g4.userName = "Please choose one of quantity";

} else {

  g4.display = display.hidden;

  g4.userName = "";

}

You do have a "setFocus()" in your original "else" block: When you hide the field, you cannot set focus to it. Also, when the field is hidden, there is no tooltip that gets displayed, so setting it to an empty string does not hurt, but it's also not necessary.

rakeshk21205956
Inspiring
January 11, 2017

Sir,

But i don't want to hide the radio buttons.. i want to make then readonly if the first radio button is not selected ....

Karl Heinz  Kremer
Community Expert
Community Expert
January 11, 2017

Your question's title says "I want to hide..."...

To set a field (or group) to read-only, you use the "readonly" property (Acrobat DC SDK Documentation). What I said about using a read-only/hidden button still applies. Change your code so that instead of setting "g4.display" use one of the following lines:

Set to read-only:

g4.readonly = true;

Set to read-writable:

g4.readonly = false;