Skip to main content
Participant
July 11, 2022
Answered

PDF Form Javascript field auto fill base on dropdown choice

  • July 11, 2022
  • 3 replies
  • 2230 views

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!

This topic has been closed for replies.
Correct answer Marcus25205867tyqw

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.

3 replies

Marcus25205867tyqwAuthorCorrect answer
Participant
July 13, 2022

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.

try67
Community Expert
Community Expert
July 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.

Participant
July 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. 

Bernd Alheit
Community Expert
Community Expert
July 11, 2022

Check the Javascript console for errors. 

Participant
July 11, 2022

It says Syntax error 7: At line 9 when i attempt to insert the code.

Bernd Alheit
Community Expert
Community Expert
July 12, 2022

The end of the switch is missing.