Copy link to clipboard
Copied
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.
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;
Copy link to clipboard
Copied
The value of a checked checkbox is "Yes" or the export value.
The value of a unchecked checkbox is "Off".
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now