Skip to main content
Participant
February 15, 2016
解決済み

If yes, text should display texta, if no, text should display textb on form

  • February 15, 2016
  • 返信数 2.
  • 657 ビュー

I have a form, that if you select yes, phrase one will appear,  if you select no, phrase 2 will appear.

I have one check box called "choice" and an empty text box called texBox.

I have tried these javascripts: inside Actions -> Mouse Up -> Run a javaScript.

Using Adobe Acrobat Pro DC

--------------------- attempt 1 --------------------------

var f = this.getField("choice").value;

if(f ="yes")

{textBox.value = "yes";}

else if(f !== "yes")

{textBox.value ="no";}

So If I click on the check box, the box should say yes.

-------------------- attempt 2 -------------------------

another attempt, using differant variables then above.

var g = this.getField("clickMe2").value;

if(g){textBox2.value = "true";}

else{textBox2.value = "false";}

-------------- attempt 3 using a drop down for yes and no  (would not want to do it this way) -----------------------

var h=this.getField("List Box8").value;

if(f =="Yes"){

this.getField("Text9").value = "YYes";}

if(f == "No"){

this.getField("Text9").value = "NNo";}

This seems so simple, but apparently not.   Please advise.

I would prefer the check box to be a pair of radio buttons,  labeled yes and no, but that did not work, so thought it would be easier just to do a check box labeled yes. which would default at No.

I would really prefer all of the questions on page one only to appear if yes was selected, but again, too complicated for me at this point.

このトピックへの返信は締め切られました。
解決に役立った回答 try67

Set up two radio-buttons with "Yes" and "No" as their values under "Radio Button Choice" in Properties - Options.

Then apply this code as their Mouse Up script:

var f = this.getField("Text9");

if (event.target.value=="Off") f.value = "";

else f.value = event.target.value;

返信数 2

try67
Community Expert
try67Community Expert解決!
Community Expert
February 15, 2016

Set up two radio-buttons with "Yes" and "No" as their values under "Radio Button Choice" in Properties - Options.

Then apply this code as their Mouse Up script:

var f = this.getField("Text9");

if (event.target.value=="Off") f.value = "";

else f.value = event.target.value;

Bernd Alheit
Community Expert
Community Expert
February 15, 2016

‌The value of a checked checkbox is "Yes" or the export value.

The value of a unchecked checkbox is "Off".

jims10931127作成者
Participant
February 15, 2016

Thanks Bernd Alheit,   I did not know about the value of "Off".   While this answer is correct, the answer by try67 better fit my needs of the radio button.  

Thanks both of you for help.