Skip to main content
Known Participant
February 14, 2025
Question

How to duplicate fields without the fields being the same

  • February 14, 2025
  • 2 replies
  • 2255 views

I have a document with a javascript to populate fields. You select an option from the dropdown. The script then populates multiple text boxes with text.

 

I want to duplicate the drop downs many times. However when i select make multiple copies it duplicates the field. But the drop down populates the same boxes not the field below. 

 

this is what happens when you select from the drop down it populates the qty. descriptin, as well as the weight

 

when i create multiple copies of the drop down this is what happens:

it only changes the top row of qty, description,and weight.

 

now if i create a new drop down instead of creating multiple copies it populates the second qty description and weight.

basically the only way i know of to fix this issue is to add a new drop down manually then input all of the drop down fields. The issue with this is i have many pages of drop downs. So this will be like 100 times i have to do this or more. Plus there is around 100 entries on each drop down to select from. this will take me alot of time to do. so i am trying to create multiple copies without them being linked. Also creating multiple copies and then changing the name does not work for me. 

 

 i hope this makes sense... its abit confusing. So if you have any questions feel free to let me know!

2 replies

PDF Automation Station
Community Expert
Community Expert
February 14, 2025

When you make multiple copies, the script is still pointing to the orginal fields to populate.  The solution is to create the first row only, write a script that anticipates the field names when Create multiple copies is used, then create multiple copies fo the entire row.  This article (with video) explains in detail how to do this:

https://pdfautomationstation.substack.com/p/anticipating-field-names-in-custom

I created a (paid for) tool for loading dropdown items from an Excel column that might be of interest to you:

https://www.pdfautomationstation.com/products/item16.cfm

 

Nesa Nurani
Community Expert
Community Expert
February 14, 2025

Does your script account for new dropdown names?

You need to adapt your script to include new names when you create multiple copies.

Known Participant
February 14, 2025

how do you adapt the script to include new names when you create multiple copies please?

 

this is the script:

 

function cDrop(qtyField, descField, weightField) {
var items = {
"XCR0051": {qty: "1", desc: "24\"CRAWLER CHASSIS FOR ICM", weight: ""},
"PCR2400": {qty: "1", desc: "24CR2 CHASSIS", weight: "61.8"},
"XCR0068": {qty: "1", desc: "10 CHANNEL CHARGER MKIII EXCLUDING LEADS AND BOX", weight: ""},
"PCA1120": {qty: "1", desc: "CR2 TEST BOX", weight: "5.2"},
"PCA0002A": {qty: "1", desc: "10/60\" MAGNETIC CONTROL SYSTEM 20MM FE FOR CANADA OPERATION", weight: "3.2 "},
"PCA0620": {qty: "1", desc: "CR2 FRONT EOP RADIO MODULE", weight: ""},
"PCA0002": {qty: "1", desc: "10/60\" MAGNETIC CONTROL SYSTEM 20MM FE", weight: "3"},
"PCA0004": {qty: "1", desc: "06/16\"MAGNETIC CONTROL SYSTEM 20MM FE", weight: ""},
"PCA0005": {qty: "1", desc: "10/60\" MAGNETIC TRACKING SYSTEM", weight: ""},
"PCA0008": {qty: "1", desc: "10/60\" MAGNETIC CONTROL SYSTEM 40MM FE", weight: ""},
"PCA0009": {qty: "1", desc: "24/72\" MAGNETIC CONTROL SYSTEM 40MM FE", weight: "3.131"},
"XCR0019": {qty: "1", desc: "10\" BATTERY PACK", weight: ""},
"XCR0034": {qty: "1", desc: "RADIO RECOVERY UNIT", weight: "0.379"},
"XCR0089A": {qty: "1", desc: "4 CHANNEL CHARGER MKIII FOR 6 INCLUDING LEADS AND BOX", weight: ""},
"XCR0076": {qty: "1", desc: "NEW SMART 200 TUBE CRADLE", weight: ""},
"PCA1080": {qty: "1", desc: "CR2 COLOUR A/V UNIT", weight: ""},
"XRT0052A": {qty: "1", desc: "6CR Battery Charger", weight: ""},
"PPA0004": {qty: "1", desc: "MOTORISED MAN TROLLEY WITH BRAKE", weight: ""},
"PXB1091": {qty: "1", desc: "JME BETATRON HANDSET", weight: ""},
"PXB0001": {qty: "1", desc: "Complete 2.5 MeV system", weight: ""},
"PXB0002A": {qty: "1", desc: "PORTABLE X-RAY BETATRON SYSTEM 2.5D2", weight: ""},
"PXB0002": {qty: "1", desc: "6CR Battery Charger", weight: ""},
"PXB0034": {qty: "1", desc: "PXB6.5 MKIII BETATRON SYSTEM", weight: ""},
"PXB0003": {qty: "1", desc: "PROCESSOR PXB6M2 SYSTEM", weight: ""},
"PXB0021": {qty: "1", desc: "PXB7.5M BETATRON SYSTEM", weight: ""},
"PXB0027": {qty: "1", desc: "MARINISED PXB7.5M2 SYSTEM", weight: ""},
"PXB0005": {qty: "1", desc: "PXB7.5 SINGLE ENERGY SAIC BETATRON SYSTEM", weight: ""},
"PXB0008": {qty: "1", desc: "PXB9 MKII FAN BEAM BETATRON DUAL ENERGY FULL", weight: ""},
"PXB0050": {qty: "1", desc: "JME PXB7.5MJ BETATRON SYSTEM", weight: ""},
"PXB0070": {qty: "1", desc: "PXBMJ CONTROL PANEL", weight: ""},
"DXB1000": {qty: "1", desc: "JME DIGITAL X-RAY BUGGY SYSTEM (DXB:1)", weight: ""},
"DXR10001": {qty: "1", desc: "DXR1 COMPLETE SYSTEM", weight: ""},
"DXR20001": {qty: "1", desc: "DXR2 SYSTEM", weight: ""},
"PXB0034Q": {qty: "1", desc: "PXB6.5 DELAY PCB", weight: ""},
"PCR1090": {qty: "1", desc: "10CR2 ICM CP300CR ARTICULATION UNIT", weight: ""},
"XCR0001": {qty: "1", desc: "6/16\" CRAWLER CHASSIS MKII 48V 7AH", weight: ""},
"GCR0020": {qty: "1", desc: "", weight: ""},
"PCR1005": {qty: "1", desc: "10CR2S CRAWLER CHASSIS", weight: ""},
"PXB0010": {qty: "1", desc: "PXB9M INDUSTRIAL BETATRON SYSTEM", weight: ""},
"PXB0004": {qty: "1", desc: "PROCESSOR PXB7.5M SYSTEM", weight: ""},
"PCA0003": {qty: "1", desc: "24/72 MAGNETIC CONTROL SYSTEM 20MM FE", weight: ""},
"PCA1000": {qty: "1", desc: "CR2 REMOTE HANDSET PACKAGE", weight: "3.2"},
"XCR0050": {qty: "1", desc: "24\" CRAWLER TEST BOX", weight: ""},
"XCR0047": {qty: "1", desc: "24\" GM D-BOX INCLUDING PCBS", weight: ""},
"XCR0046": {qty: "1", desc: "24\" E-BOX ICM/BALTEAU COMPLETE", weight: "10"},
"XCR0045": {qty: "1", desc: "24\" CRAWLER BATTERY PACK", weight: ""},
"PCR1070": {qty: "1", desc: "10CR2 SETBACK CRADLE YXLON/ICM", weight: ""},
"PCR1050": {qty: "1", desc: "10CR2 CF3 ARTICULATION UNIT", weight: "16.5250"},
"PCA1150": {qty: "1", desc: "10CR2 ICM ARTICULATION UNIT", weight: ""},
"PCR1000": {qty: "1", desc: "10CR2 CRAWLER CHASSIS", weight: "38"},
"PCR1040": {qty: "1", desc: "10CR2 COMET/YXLON ARTICULATION UNIT", weight: ""},
"XCR0029": {qty: "1", desc: "10\" CRAWLER RECOVERY UNIT (12-30\")", weight: ""},
"XCR0025A": {qty: "1", desc: "10\" E-BOX MKIII (COMET/YXLON)", weight: ""},
"XCR0024": {qty: "1", desc: "10\" E-BOX MKIII COMPLETE", weight: "5"},
"XCR0020": {qty: "1", desc: "10\" CRAWLER CHASSIS MKIII", weight: "34"},
"XCR0060": {qty: "1", desc: "10/24\" ARTICULATION UNIT FOR ICM C2503 X-RAY TUBE", weight: "12.6"},
"XCR0018": {qty: "1", desc: "10\" CRAWLER CHASSIS BALTEAU", weight: ""},
"XCR0025": {qty: "1", desc: "10\" E-BOX SMART COMPLETE", weight: ""},
"XCR0042": {qty: "1", desc: "10\" SMART CHASSIS FOR SMART 200CTH TUBE", weight: ""},
"PCR1071": {qty: "1", desc: "10\" SMART CHASSIS FOR SMART 200CTH TUBE", weight: ""},
"XCR0022": {qty: "1", desc: "10\" GM D-BOX", weight: "1.0200"},
"XCR0081": {qty: "1", desc: "10\" TEST BOX FOR MKIII", weight: ""},
"PXT0620": {qty: "1", desc: "6CR2 ICM CP160CR TUBE ASSEMBLY (INCLUDES X-RAY TUBE)", weight: ""},
"XCR0016": {qty: "1", desc: "6\" CRAWLER TEST BOX", weight: ""},
"PCR0600": {qty: "1", desc: "6CR2 CHASSIS", weight: "14.4"},
"XCR0015": {qty: "1", desc: "6\" CRAWLER RECOVERY UNIT", weight: ""},
"XRT0064": {qty: "1", desc: "KEY SWITCH SAFETY UNIT FOR ICM CP160 TUBES", weight: ""},
"XCR0004": {qty: "1", desc: "6/16\" & 8/18\" CRAWLER BATTERY CHARGER (2 X 24V)", weight: ""},
"XCR0093": {qty: "1", desc: "TUBE MOUNT (COMET/YXLON)", weight: ""},
"PCR1060": {qty: "1", desc: "10CR2 CF3 ARTICULATION UNIT", weight: ""},
"XCR0049": {qty: "1", desc: "24\" SPARES PACKAGE", weight: ""},
};
var item = items[event.value] || {qty: "", desc: "", weight: ""};
this.getField(qtyField).value = item.qty;
this.getField(descField).value = item.desc;
this.getField(weightField).value = item.weight;
}

 

 

PDF Automation Station
Community Expert
Community Expert
February 14, 2025

What are the dropdown, qtyField, descField, and weightField names in the first row?