Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Please how do i add code to enable addition? *All details below*

Community Beginner ,
Sep 10, 2024 Sep 10, 2024

i have a drop down with this code: 

} else if (event.value=="") {
this.getField("Text1").value = "1";
this.getField("Text2").value = "";
this.getField("Text3").value = "KG"
} else {
this.getField("Text1").value = "1";
this.getField("Text2").value = "";
this.getField("Text3").value = "KG";
}

I am trying to add code so i can add all of the weights together for the net weight to be populated in another text box. is this possible and can anyone help me do it please? thank you!

TOPICS
JavaScript
7.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Here is your file with changes made (Step 1), first two fields will work, rest you need to fill on your own:

https://drive.google.com/file/d/1QKDb1RA01bM8x7BGNaz89FBPQVPLNUG1/view?usp=sharing 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2024 Oct 03, 2024

i can keep the validation script as "description" even though i changed the name to "text field" in the screenshot?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2024 Oct 03, 2024

Charlie303735890y2h_0-1727967793968.png

when trying to enter the code into the document level java script i get the following error message... any help please?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2024 Oct 03, 2024

You need to have a comma in each line after closing the curly bracket, only the last line doesn't need a comma.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2024 Oct 03, 2024

Charlie303735890y2h_0-1728024093183.png

i put a comma after the curly bracket and it still gives me the same error message?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2024 Oct 03, 2024

is there no way to delete comments on here? that was the issue it now works i am now going through and adding commas in the right place. i will let you know how i get on.

 

thank you very much for all the help its much appreciated 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2024 Oct 03, 2024

sorry wrong screenshot i meant this one:

 

Charlie303735890y2h_0-1728024806047.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2024 Oct 04, 2024

The error is in the line above  the blue line.

You miss a \ before ".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2024 Oct 04, 2024

thank you very much for the help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2024 Oct 03, 2024

Charlie303735890y2h_0-1728024717851.png

after adding commas after every curly bracket i get this error messsage

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2024 Oct 04, 2024

i have now gotten rid of the error messsages in the code. However when inputting all of the codes into the drop down, when making a selection it does not do anything. Could you please just check the first line/dropdown to see where i have gone wrong please? thank you 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2024 Oct 04, 2024

Check the Javascript console (ctrl-j) for errors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2024 Oct 04, 2024

Your field is named "qty1" not "QTY1".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2024 Oct 04, 2024

When i change the quantity field to QTY1 it now only works for the quantity field.  it populates as 1. However the description and weight does not populate. 

Charlie303735890y2h_1-1728036988283.png

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2024 Oct 04, 2024

In the list for "XCR0001" you have space " XCR0001", you have a lot of entries like that, if you use "XCR0001" instead of " XCR0001" it will work,
fix that for all entries.
Also you have a lot of duplicates.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2024 Oct 04, 2024

ive deleted all the duplicates, removed the spacing. to the point where the whole dropdown works when i make any selection from the drop down. i have almost finished the entire document however i noticed some lines just do not work. which is weird because im doing the exact same thing as the rest of the document.

 

for example: 

Charlie303735890y2h_0-1728048425935.png

the qty,description and weight follow the same suit for 23/24. however qty24 when makking a selection does not popoulate anything.

Charlie303735890y2h_1-1728048533648.png

Charlie303735890y2h_2-1728048543911.png

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2024 Oct 04, 2024

"QTY 24" have space in its name and in the script you use without space "QTY24".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2024 Oct 04, 2024

almost all the code/document works. however, i have noticed that for some reason there is a few random 'KG' fields apppearing in the weight field. i removed all 'kg' so that only the numbers appear to make the calculations easier. However they somehow appear again... but only on some lines and not others which makes no sense as its a document level script and should populate everything the same. Could you please take a look at the document please. thank you very much. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2024 Oct 04, 2024
 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2024 Oct 04, 2024

On the second page, you didn't remove custom calculation scripts from dropdown fields.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 07, 2024 Oct 07, 2024

Charlie303735890y2h_0-1728288855207.pngCharlie303735890y2h_1-1728288868183.pngCharlie303735890y2h_2-1728288873334.png

on the first page i removed the custom scripts and it still shows as kg as the default value.

 

also the drop down when selecting options does not work even though i filled in the new code

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 07, 2024 Oct 07, 2024

nevermind. somehow removing the script from the second page effected the first page. i was using the first page as a test for your new code and left the second page as it is. when i updated the second page it fixed my issue on the first page. i am going to run some tests on the document but it all appears to be working like a charm. plus you have fixed my issue of the code being duplicated 60 times. this will help massively when i update weights as i only need to do it once rather than 60 times.

 

i cant thank you enough for all the help. i am sorry i made it so painful. but we got there in the end haha. if i have any other issues i will let you know, but for now all i can say is thank you 🙂 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2024 Oct 10, 2024

could you help me with another issue im having please with a different document? its driving me crazy haha

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 10, 2024 Oct 10, 2024

Post a new question

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2024 Oct 10, 2024
LATEST

Okay thank you 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2024 Oct 04, 2024

Check also the other field names.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines