Copy link to clipboard
Copied
I am working on creating a pdf form using Adobe X pro to in my job and looking to take a Starting Number and have it go up by one every time it is used does anyone know how I can do it? I am using Java Scripts for other thing in the form?
- You can add the code that increments the value of the counter field to your existing code. For example, put it in the SetFieldValues function.
- Under the Properties of the drop-down field, in the Options tab, tick the box that says "Apply the selected value immediately".
Copy link to clipboard
Copied
Let's say the field is called Counter. Enter this code as a new script under Tools - JavaScripts - Document JavaScripts (call it "init", for example):
this.getField("Counter").value = Number(this.getField("Counter").value)+1;
If you don't want that number to be reset when the form is cleared, enter this line as well:
this.getField("Counter").defaultValue = this.getField("Counter").valueAsString;
Copy link to clipboard
Copied
TRY67 Thank you for your Suggestion I placed both lines in the same script and it does not appear to work . i have info being Filled out based on a drop down Choice . it is not clearing the number when i reset it based on the drop down but the number is not increasing. also do you know how to change the form based on the dropdown choice without having to reset every time?
Copy link to clipboard
Copied
Check the JS Console (Ctrl+J) for error messages.
I don't quite understand what you mean about changing the form based on a dropdown choice.
Copy link to clipboard
Copied
on my form I am using the a dropdown to Populate the fields on the form via a Java Script (see below) . when I switch to the Blank Selection it reset the form using
if( event.willCommit ) {
if(event.value == "") this.resetForm(["DeptContact","DeptEmail","DeptNumber"]); else SetFieldValues(event.value);
}
then using the Java Script below I am Populating some of the fields to auto fill in based on my Choice from the drop down.
// Place all pre-population data into a single data structure
var DeptData = { Accounting:{ contact: "Steala Damuni", email: "accounting@mycomp.com", deptnum: "cmp1234" }, Engineering:{ contact: "Frank N. Stien", email: "engineering@mycomp.com", deptnum: "eng1234" }, Marketing :{ contact: "Shelly Oughtbuks", email: "marketing@mycomp.com", deptnum: "mkt1234" }, ITSupport:{ contact: "Goah Wei", email: "it@mycomp.com", deptnum: "its1234" }};
function SetFieldValues(cDeptName) {
// Populate fields with values from the Department Data Object
this.getField("DeptContact").value = DeptData[cDeptName].contact;
this.getField("DeptEmail").value = DeptData[cDeptName].email;
this.getField("DeptNumber").value = DeptData[cDeptName].deptnum;
}
I am trying to get the job # field to add one when I switch jobs and then also when switching from ( MASS_FAMILY_STATEMENTS to NORTHERN LIGHTS STATEMENTS it to switch the data with our having to Click on the Blank to Reset the Form
Copy link to clipboard
Copied
- You can add the code that increments the value of the counter field to your existing code. For example, put it in the SetFieldValues function.
- Under the Properties of the drop-down field, in the Options tab, tick the box that says "Apply the selected value immediately".
Copy link to clipboard
Copied
Thanks that worked
Find more inspiration, events, and resources on the new Adobe Community
Explore Now