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.
Related
I had a class assignment to create a form letter that allows form input to insert the entered data into the document once a submit button is pressed.
The newest assignment instructs me to add a new input field to allow me to input the number of recipients to create this letter for, such that I input a number and hit enter, and the document updates to have multiple input fields for each recipient in a JS array. Then, I can type in a new receipient name in each field created, and have a new page create the mockups of the letter to each recipient recursively.
In other words, the web page says "How many people do you want to send this to?" - I put in a number, hit enter, and the page updates for a "Name" field for each person, plus the other fields. Then, after all fields are filled and submit is pressed, a new page opens and shows the full form letter for each name I input.
I dont have a clue how to do this, and I bumbled through the initial assignment. Any suggestions? And yes, I'm a 100% JS noob, and I'm not all that well versed with HTML5 either, so please be verbose and gentle with me. :)
Thanks!!
I am the opposite of a code monkey, so please forgive me if this is a simple solution. I have searched and searched and though I've found possible code examples, cannot find any information on how to fix the issue.
I've created a form-fillable PDF. I have fields that calculate based on inputs. I have a dropdown box that auto-populates some of the numbers (to add to the manual inputs). All of these work great!
I thought I would get fancy and further fill some of my data in the form. This is where the problems get funky.
I am setting the fields as shown, but those numbers can no longer be modified afterward.
this.getField("RanksPsy").value = psy;
this.getField("RanksBlade").value = blde;
this.getField("RanksBrawl").value = brwl;
this.getField("RanksCou").value = cou;
this.getField("RanksDip").value = dip;
I have buttons to increase/decrease the Ranks... fields, but the dropdown locks them and I'd like to avoid that if possible.
Is there another way to set those fields without using this.getField?
Thank you.
If I'm honest, I didn't understand the question well š
I don't recognize the getField function, so I decided to google it and found a RAD PDF documentation, so I'm assuming that's the library you're using to do this.
As that documentation states,
getFunction gets the first PDF form field object in the loaded
PdfWebControl document with a given name.
And this is the example provided, it may help.
var field = myApi.getField("Test Name");
if(field) {
//set its name to "New Name"
field.setProperties( {"name" : "New Name"} );
}
The solution to this is to put the script as an 'on blur' event rather than a keystroke event. It writes the data and then leaves it alone, which is exactly what I was looking for.
I am building a form for users to submit a list of their items that they want to move.
I use Wordpress with FormCraft Premium plugin which has the option to include a choice matrix (checkbox) in the form.
I want users to tell me how many beds do they have, how many night stands, how many mirrors, TVs, etc.
But the problem is that by default users can't uncheck a choice that they make.
So if a user selects accidentally that he has 4 TVs, he can't later uncheck that by clicking on that radio button again.
He is only able to select another radio button (1, 2, 3 or 5+) which is bad in cases when user doesn't have any TVs.
Could you please tell me how is it possible to fix this?
Here is the URL to my form: https://www.tajnezdravlja.com/form-view/4
I guess this can be solved only by using javascript.
I don't have any experience with javascript, I know only HTML and CSS.
I don't know where can I see any relevant code, as I don't have experience with .js
When I inspect the site and open console I don't see anything relevant.
However, the FormCraft plugin has an option to add custom javascript code to the form.
It says in admin panel:
Custom JavaScript
Add any JavaScript code in here, and it will be executed on page load. You don't have to use tags. Make sure this is valid JavaScript!
When I click once on a choice, I expect it to be checked and that happens, that is ok.
But when I click again on the same choice, I expect it to become unchecked, but it remains checked. That is the problem.
Try adding this to Custom JavaScript. It allows users to toggle the radio input type in the matrix fields.
jQuery('.fc-form .matrix-cover :radio').mousedown(function(e){
var jQueryself = jQuery(this);
if( jQueryself.is(':checked') ){
var uncheck = function(){
setTimeout(function(){jQueryself.removeAttr('checked');},0);
};
var unbind = function(){
jQueryself.unbind('mouseup',up);
};
var up = function(){
uncheck();
unbind();
};
jQueryself.bind('mouseup',up);
jQueryself.one('mouseout', unbind);
}
});
I have created a huge button covering my whole PDF file. I want to fill it in white if the necessary fields in the PDF form are not filled in.(This is to prevent people from skipping required fields. My javascript code is listed below. I have initially filled in the button using Adobe Acrobat Pro, I am then trying to remove the button if the "year" field is completed.
var aNames = ["year"];
var bComplete = true;
var cValue ="";
for(i=0;i<aNames.length;i++){
cValue=this.getField(aNames[i]).value;
if(cValue==this.getField(aNames[i]).defaultValue){
bComplete=false;
}
}
if(bComplete==true){
document.getElementById("Button1").remove();
}else {
app.alert("Please complete form",0,0);
}
This looks very much like influenced by webbrowser JavaScriptā¦
The first issue is the button; if it covers the document, how can you fill the form (or does it cover subsequent pages?).
About the JavaScript, you do not need to create an array of field names, you know the fields directly, so you can address them directly, without having to loop, as in:
if (this.getField("myYear").value != this.getField("myYear").defaultValue)
Of course, if you have a bunch of such fields, it may be an idea to create a document-level array of the field names.
Next, you won't remove the button field, but you simply hide it, as in:
this.getField("myCoverButton").display = display.hidden ;
It might be a good idea to have a look at the Acrobat JavaScript documentation, which is part of the Acrobat SDK, downloadable from the Adobe website.
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.