I am currently designing a PDF form that contains a certain level of automation in the form of text boxes being completed based on radio button selection. I have got the following code for a text box that basically says if you select Choice 2 which is No then input "N/A" into the text box.
var v = this.getField("Group3").valueAsString;
var x = this.getField("Group1").valueAsString;
if (v=="Choice2" && x=="Choice2") event.value = "N/A";
if (v=="Choice1" && x=="Choice1") event.value = "";
What I want is if a person selects No and then change their mind to Yes, it removes the N/A and then allows them to type their own input. What it currently does however is remove the N/A but then also removes any input a person makes as the code is telling the text box to always read as blank.
Please forgive my question as I know it is very basic but I am just starting out with Javascript and integration of Javascript into PDFs in general.
Thank you
Related
I'm a beginner in Adobe Acrobat and javascript.
I have to create a form for my company. When the user select a department (this is a radio button), it should select automatically the signature group (which is another radio button.
This is what i got so far:
var a = this.getField("OtherCompanyDAN");
var b = this.getField("alias-dentsu");
if(a.isBoxChecked(0))
b.checkThisBox(0,true);
else
b.checkThisBox(0,false);
I know this code is supposed to work with the CheckBox, I have no clue how to translate it with radio button.
Could you help me ?
Thanks in advance!
Does anyone have experience with javascript in Adobe Acrobat DC?
I am trying and making dynamic stamps, and with the help of various guides and tutorials, I can solve what I want with one input field.
It looks like this:
var cAsk = "Anvises til udbetaling";
var cTitle = "ATU"
if(event.source.forReal &&
(event.source.stampName == "#stamp1"))
{
event.value = app.response(cAsk, cTitle);
}
The above provoke a javascript popup with an input field that you can type in, and it will appear on the stamp.
My problem is for multiple input fields, so I would like all inputs to be filled in in the same popup, instead of each input having its own popup as is the case with the javascript inserted in pastebin.
It's easier annoying when you have seven fields to fill in, then you meet seven popups followed by each other. instead of just being able to fill in the seven fields in the same popup :)
You would use the app.execDialog function. You can have multiple text fields, check boxes, radio buttons, dropdowns, listboxes, etc. It's not easy but you can read about it here.
Type 'execDialog' in the search field.
I am using a simple JS here:
var person = prompt("how are you feeling today?", "");
And I would like the text input area (NOT the whole box, ONLY the area where you type in the text) to be bigger... like a comment section.
Any ideas please?
The text input box here is supplied by the browser of the client and therefore cannot be changed in any way with CSS styling. You could instead create a custom popup which is part of your website, allowing you to style it however you would like.
My objective is to accumulate results of a multi-page questionnaire form into a summary page. Specifically I wish to take the selection from radio buttons and check boxes and place their values into another field on the summary page. This works fine when the radio button selections are numbers. I use the following script in the calculation pane (Custom calculation script) of the destination field of the summary page e.g.
var v1 = +getField("Hx.LBPWorst").value;
event.value=v1
The variable Hx.LBPWorst is a radio button with 11 buttons, 0-10 and the selected option is transferred to another field on the summary page without problems
My problem is that I wish to transfer text choices rather than numbers from a radio button E.g.
The radio button Hx.mech.prosit has four options “Worse”, “Better”, “NE”, “Varies”. The destination field for the selected option is a field with the format set to “None”. I have attempted to use the same structure i.e.
var v2 = +getField("Hx.mech.prosit").value;
event.value=v2
In this case the destination variable is filled with NaN i.e. Not a Number. I have read some of the questions and answers in this forum and apparently the problem is that radio buttons actually don’t store the selection as text. How can I achieve my objective and still use radio buttons (or check boxes)?
Change +getField to getField
var v2 = getField("Hx.mech.prosit").value;
The Unary plus (+) is changing the string to a number. When it can not convert it to a number, you get the NaN.
I have created a new window and have fields that need to be completed, one a text field (for a numeric value) and the other is a radio button option (choose between 7 radio buttons). I can enter text and select a radio button but cannot obtain the value for the field id, e.g. myWindow.document.write ('Copies required: ') and for the button choice
myWindow.document.write ('6x4 ').
How do I obtain the value for copies and tell if the radio button has been checked. Have displayed the value for copies and always says undefined. Any help would be very much appreciated. Thanks.
How did you displayed the value?
In simple javascript it should be a code like:
alert(document.getElementById('IdofyourObject').value);
If you are using jQuery it would be:
alert($('#IdofyourObject').val());
Maybe you can share your code.