Skip to main content
gamzes93533812
Known Participant
November 9, 2017
Answered

show/hide textbox on radio button

  • November 9, 2017
  • 1 reply
  • 4717 views

Cheers!

I know that it is an issue that is discussed and solved in various platforms, but i have a very (probably quite simple) issue that I can not solve.

I believe I am missing a small but some important parameter since I am new to js.

Basically, I am creating a pdf form in Acrobat.

I have 6 radio buttons in a group (group name: Group1) and each have different names.

Independent than that I have some text field (layer name: "DayMonth-1") that I would like to display (which is hidden in default) if the user selects for example first radio button (layer name: "un_jour_precis" under Group 1).

I used the following code as a MouseUp Event for my radio button:

var x = this.getField("un_jour_precis");

if (x.value = "Off") {

    this.getField("DayMonth-1").display = display.visible;

}

else {

    this.getField("DayMonth-1").display = display.hidden;

}

But, nothing happens

I would appreciate any corrections/suggestions!

This topic has been closed for replies.
Correct answer try67

Here comes my file:

https://we.tl/RjgfKKvF0H

The field of interest is group6>un_jour_precis (where I tried to assign a js comment)


OK, I see the issue now. "un_jour_precis" is not a field name, it's the "radio button choice" value of a specific radio-button in the "Group6" field. What you tried to do is a bit tricky, so I wrote for you the code that does it:

if (event.target.value != "un_jour_precis") {

    this.getField("DayMonth-1").display = display.visible;

} else {

    this.getField("DayMonth-1").display = display.hidden;

}

You should apply it to ​all of the radio-buttons in the group for it to work correctly.

1 reply

try67
Community Expert
Community Expert
November 9, 2017

You've made a classic mistake of assigning a value instead of comparing it...

Change this line:

if (x.value = "Off")

To:

if (x.value == "Off")

gamzes93533812
Known Participant
November 9, 2017

Thank you for your answer.

I replaced my

"=" with "=="

but still not working.

try67
Community Expert
Community Expert
November 9, 2017

Check the JS Console (Ctrl+J) for error messages.