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

Form Fields and Auto-fill

New Here ,
May 27, 2016 May 27, 2016

So, my situation is that I have several forms that have varying pricing based on a single number.  For instance, we have a set of 6 different prices based on the number of hours a program lasts.  Ideally, I would open the document, navigate to the form field titled "HoursPricing" and enter a value -- for starters lets say "3".  After entering this value, the form would auto-fill the prices into the proper positions.

So visually it would look something like...

Hours Pricing: 3

Price1: 170

Price2: 210

Price3: 300

I have a separate spreadsheet with the price lists based on the hours pricing and am fine manually typing in each individual price but if I only had to do that once, then every subsequent time only have to type "3" to get that pricing profile to auto-populate it would make life super easy.  It sounds a lot like an "If/Then" statement but I don't have enough experience with Acrobat to even begin to test any formulas I've seen online.

Maybe form fields aren't the best way to do it, or there isn't a way to set it up.  Any thoughts are appreciated.

TOPICS
Acrobat SDK and JavaScript , Windows
448
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 ,
May 27, 2016 May 27, 2016

Form fields are the only way of doing it, and the code involved is not that complicated, really.

If you want all of the code to be located in one place then you can use the custom validation script of the Hours Pricing field.

The code would look something like this:

if (event.value==3) {

    this.getField("Price1").value = 170;

    this.getField("Price2").value = 210;

    this.getField("Price3").value = 310;  

} else if (event.value==5) {

    this.getField("Price1").value = 190;

    this.getField("Price2").value = 230;

    this.getField("Price3").value = 350;

// etc.

} else {

    this.getField("Price1").value = 0;

    this.getField("Price2").value = 0;

    this.getField("Price3").value = 0;

}

It's also possible to do it with the data file itself, but that would require a much more complex script.

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
New Here ,
Jun 07, 2016 Jun 07, 2016

Okay, awesome!

Forgive my ignorance, but would this be put in the javascript debugger window?

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
New Here ,
Jun 07, 2016 Jun 07, 2016

Actually found where to put the code and it's working like a dream.

One other question, though.  Can you put a character in with where the Value would be like...

   

  1.     this.getField("Price3").value = $350
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 ,
Jun 07, 2016 Jun 07, 2016

The value should only be the number. The currency symbol should be added by

setting the correct Format option.

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
New Here ,
Jun 07, 2016 Jun 07, 2016
LATEST

Thanks!!  Working great!

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