Copy link to clipboard
Copied
We have tried a variety of methods and javascript and absolutely nothing will work. Ideas and help are greatly appreciated!
Here are two codes we tried with no luck:
var A = this.getfield("Group16").value;
var Y = this.getfield("Text21").value;
var Z = this.getfield("Text22").value;
if (A=="Choice1")
document.getElementById("Text27").value = Y;
else document.getElementById("Text27").value = Z;
document.getElementById("Text27").value=this.getElementById("Group16").value;
#2:
var S = this.getfield("Text21").value;
var T = this.getfield("Text26").value;
{
if(Group16.value=="Choice1"){
var S=this.getfield("Text21")
}
else{
var S=this.getfield("Text26")
}
}
OK. Then use this code as the custom calculation script of "Text3":
var a = this.getField("Group16").valueAsString;
var b = this.getField("Text1").valueAsString;
var c = this.getField("Text2").valueAsString;
if (a=="Choice 1") event.value = b;
else if (a=="Choice 2") event.value = c;
else event.value = "";
Copy link to clipboard
Copied
Is this code for a PDF file or an HTML file?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
OK. Then you're in the right place, but you're quite far away from viable code. Your first code is for HTML pages, so don't bother with it.
I recommend you spend some time studying the correct syntax from Acrobat JS and then try again, or at least provide a better explanation of what you want to achieve.
Copy link to clipboard
Copied
Ok, thank you. That is good to know. I am very new to javascript.
What we are trying to do is in an fillable form, we want the applicant to choose "Choice 1" or "Choice 2" using radio buttons. Once they have selected their choice, we want that radio button to pull a value from a different text field (i.e Text1) and put that value in a third text box (i.e Text3). The idea is if the applicant chooses Choice 1 it will pull the value from Text1 and put it in Text3. If they choose Choice 2 it will pull the value from Text2 and put it in Text3. Does that make sense?
Thanks again for the help!
Copy link to clipboard
Copied
Should Text3 be editable by the user, or should its value be determined only by the radio-button (and other text field)?
Copy link to clipboard
Copied
It should not be editable. The value should be determined only by the radio-button.
Copy link to clipboard
Copied
OK. Then use this code as the custom calculation script of "Text3":
var a = this.getField("Group16").valueAsString;
var b = this.getField("Text1").valueAsString;
var c = this.getField("Text2").valueAsString;
if (a=="Choice 1") event.value = b;
else if (a=="Choice 2") event.value = c;
else event.value = "";
Copy link to clipboard
Copied
That worked! Thank you so much! It is greatly appreciated!!!
Copy link to clipboard
Copied
I am trying to accomplish something very similar to my PDF form. In my form, I have a set of Radio buttons; Choice 1 is "Full Service," Choice 2 is "Half Service." Then I have a set of radio buttons for "Once, Twice, or Three days a week." Depending on the results, "service" and "days," I would like this to autofill a number from a text field (rate chart). Can you help with this?
Copy link to clipboard
Copied
First, do a little searching on this forum. This exact question has been answered many times. Ohh, like right here in this thread.
Next, please start a new topic.
Copy link to clipboard
Copied
Thank you Thom Parker,
I thought I was in the right place. Here is as far as I have been able to get.
var a = this.getField("Group16").valueAsString;
var d = this.getField("Group17").valueAsString;
var h = this.getField("Text8").valueAsString;
var i = this.getField("Text9").valueAsString;
var j = this.getField("Text10").valueAsString;
var k = this.getField("Text11").valueAsString;
var l = this.getField("Text12").valueAsString;
var m = this.getField("Text13").valueAsString;
if (a=="Choice1",d=="Choice1") event.value = h; else
if (a=="Choice1",d=="Choice2") event.value = i;
else if (a=="Choice1",d=="Choice3") event.value = j;
else event.value = "";
if (a=="Choice2",d=="Choice1") event.value = k;
else if (a=="Choice2",d=="Choice2") event.value = l;
else if (a=="Choice2",d=="Choice3") event.value = m; else event.value = "";
And this works to a point. I can't get it to recognize "Choice2". Suggestions on what to search for?
Thank you in advance.
Copy link to clipboard
Copied
if (a=="Choice1",d=="Choice1")
What is the behavior you are expecting from this "if" condition?
Have you read this article?
https://www.acrobatusers.com/tutorials/conditional-execution/
Also watch the video Console Window here:
https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro
Copy link to clipboard
Copied
Thank you, that video and article was the precise thing I was looking for. As a designer, I am not the best at code and I would like to get better. I will follow through with more classes and tutorials.
Thank you again.
Copy link to clipboard
Copied
how would you make the (Text3) editable?
thanks in advance
Copy link to clipboard
Copied
Read this:
https://www.pdfscripting.com/public/Editing-Fields-Properties.cfm
Copy link to clipboard
Copied
how would it look if (Text3) was to be editable?
TIA
Copy link to clipboard
Copied
Thanks for you response. i am using Java Script for BlueBeam forms so i dont have the same Adobe windows shown in the example , i have been finding the scripts and copy paste ...
this is the script i am using
var v = this.getField("Group1").value;
if (v=="Choice1") event.value = "01";
else if (v=="Choice2") event.value = "012"; else if (v=="Choice3") event.value = "03";else if (v=="Choice4") event.value = "011";else if (v=="Choice5") event.value = "02";else if (v=="Choice6") event.value = "04";// etc.
else event.value = "";
i would like to add a (Choice7) that would allow the user to fill in the text box with anything thety would like.
Copy link to clipboard
Copied
Just drop the final part:
else event.value = "";
Copy link to clipboard
Copied
If this is for a PDF, then you'll need to learn a bit about PDF forms and the PDF JavaScript model.
See the videos posted here to get you started:
PDF Form Field Scripting Basics - YouTube