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

PDF Form Javascript field auto fill base on dropdown choice

Community Beginner ,
Jul 11, 2022 Jul 11, 2022

Greetings,

I am creating a PDF but having some techincal issues.

Here is an image for reference.

There is a dropdown list named Materials. I would like the Material Price and the Line Total to be set to $58.00 when you've picked INCOMING MINIMUM LOAD 500.

So far i've tried this script to no avail, 

var f = this.getfield("Material");
switch(event.value){
case "INCOMING MINIMUM LOAD 500 ":
f.setMaterialPrice(58);

Any help would be greatly appreciated!

TOPICS
Create PDFs , Edit and convert PDFs , General troubleshooting , How to , JavaScript , PDF forms
2.0K
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 Beginner ,
Jul 13, 2022 Jul 13, 2022
LATEST

To be more succinct, I was trying to change a field based on a combo list choice. Upon some research i've found the solution on this page. Changing another field with combo box (drop down) selection.  Thanks.

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 Expert ,
Jul 11, 2022 Jul 11, 2022

Check the Javascript console 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 Beginner ,
Jul 11, 2022 Jul 11, 2022

It says Syntax error 7: At line 9 when i attempt to insert the 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 Expert ,
Jul 11, 2022 Jul 11, 2022

The end of the switch is missing.

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 ,
Jul 11, 2022 Jul 11, 2022

You can't just invent stuff and expect it to work.

setMaterialPrice is not the name of a Field object's method.

To set a field's value you must use the value property, like this:

f.value = 58;

 

Also, JS is case-sensitive, so "getfield" will not work. It's "getField".

 

And using a switch for a single comparison doesn't make sense, either. Use an if command.

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 ,
Jul 13, 2022 Jul 13, 2022

Thanks for the input. I've never scripted in JavaScript or any language for that matter. I guess it's time to learn! Trying f.value right now. 

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 ,
Jul 13, 2022 Jul 13, 2022
LATEST

To be more succinct, I was trying to change a field based on a combo list choice. Upon some research i've found the solution on this page. Changing another field with combo box (drop down) selection.  Thanks.

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