Copy link to clipboard
Copied
I have made a form with the purpose of having multiple dropdowns for inserting an 'ID number' which would then populate the following text fields: 'description,' 'quantity,' and a 'unit.' This works perfectly with this code (Custom Keystroke Script) for the dropdown labelled: "ID1"
"
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["Desc1","Quan1","Unit1"]);
else
SetFieldValues(event.value);
}
"
And a 'Document Javascript' named "SetFeildValues" with the following code:
"
// Place all prepopulation data into a single data structure
var DeptData = {
// HEADINGS***********************************
1000:{
description: " MAIN HOUSE ROOFING",
quantity: "",
unit: ""
},
1001:{
description: "CARPORT",
quantity: "",
unit: ""
},
// ROOFINGS
BC:{
description: "BUILDING CERTIFICATION: All Building Approvals And Certification Upon Completion Of Works Following QBCC And Local Council Specifications.",
quantity: "1",
unit: "each"
},
1:{
description: "Supply & Fit Colorbond Roof Sheets, Including, Valley Irons, Barge Roll Flashings And Capping’s As Required. Profile: Custom Orb.",
quantity: "",
unit: "sqm"
},
2:{
description: "RUBBISH REMOVAL: Remove, Recycle And Dispose Of Existing Roofing And Debris.",
quantity: "1",
unit: "each"
},
3:{
description: "Remove, Supply And Install Metal Roof Battens To Correct Spacings to Facilitate Works.",
quantity: "",
unit: "lm"
},
4:{
description: "Supply and Install Sarking to Entire Roof During Roof Replacement.",
quantity: "",
unit: "sqm"
},
5:{
description: "GUTTERS: Remove And Replace Gutter To Match Existing As Close As Possible.",
quantity: "",
unit: "lm"
},
6:{
description: "Trestle And Plank Hire To Facilitate Gutter Replacement.",
quantity: "1",
unit: "each"
},
7:{
description: "WHIRLY BIRD: Remove, Supply And Replace Whirlybirds To Match Existing As Close As Possible.",
quantity: "1",
unit: "each"
},
8:{
description: "AERIAL REFIT: Remove And Refit Aerial/Antenna (Including Reconnection).",
quantity: "1",
unit: "each"
},
9:{
description: "Toilet - Hire Of Chemical Site Toilet, Cleaned Out Once A Week. Including Pick Up And Drop Off",
quantity: "1",
unit: "each"
},
10:{
description: "QBCC Home Warranty Insurance As Per Council And QBCC GUIDELINE: Prepare, Purchase And Issue Required QBCC Home Warranty Insurance.",
quantity: "1",
unit: ""
}
};
function SetFieldValues(cID1)
{
this.getField("Desc1").value = DeptData[cID1].description;
this.getField("Quan1").value = DeptData[cID1].quantity;
this.getField("Unit1").value = DeptData[cID1].unit;
}
"
The problem arises when I try to add more columns with the same goal as the first.
My thought process is that I will have to make a Custom Keystroke Script)for the next dropdown labelled: "ID2," "ID3," ... ect with the following code:
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["Desc2","Quan2","Unit2"]);
else
SetFieldValues(event.value);
}
and add the following code to the 'Document Javascript' named "SetFeildValues"
function SetFieldValues(cID2)
{
this.getField("Desc2").value = DeptData[cID2].description;
this.getField("Quan2").value = DeptData[cID2].quantity;
this.getField("Unit2").value = DeptData[cID2].unit;
}
However when I do this the second dropdown "ID2" links with "desc1," "quan1," and "unit1."
Please help or direct me, Thank you all kindly in advance.
Link to the PDF in here:
https://drive.google.com/file/d/1Ewe577rn8QMNb3g1sBirRUNpXE47eof-/view?usp=sharing
You have two different functions with the same name. You should change the name of the second SetFieldValues function and call that as needed.
But it would be better to change the function so that the column number is passed as an argument, and the function becomes:
function SetFieldValues(cID, column) {
this.getField("Desc" + column).value = DeptData[cID].description;
this.getField("Quan" + column).value = DeptData[cID].quantity;
this.getField("Unit" + column).value = DeptData[c
...
Copy link to clipboard
Copied
You have two different functions with the same name. You should change the name of the second SetFieldValues function and call that as needed.
But it would be better to change the function so that the column number is passed as an argument, and the function becomes:
function SetFieldValues(cID, column) {
this.getField("Desc" + column).value = DeptData[cID].description;
this.getField("Quan" + column).value = DeptData[cID].quantity;
this.getField("Unit" + column).value = DeptData[cID].unit;
}
Copy link to clipboard
Copied
Thank you for the quick reply and help.
WARNING: I'm a novice at javascript in acrobat.
How would I be able to assign the column number to the fields and dropdowns?
Thank you again for your help!
Copy link to clipboard
Copied
Thank you for the quick reply and help.
WARNING: I'm a novice at javascript in acrobat.
How would I be able to assign the column number to the fields and dropdowns?
Thank you again for your help!