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

Setting a form field to auto fill based on another field

New Here ,
Aug 05, 2016 Aug 05, 2016

Copy link to clipboard

Copied

I am creating a scorecard to be used by my companies inside sales group.

I need to set the form so that if data is entered into one field, a specified number will automatically populate in another field.

Example:

IF a "Follow-Up Quote #" field is filled in THEN a 3 will automatically be entered in the corresponding "Pts" fiield

IF a "New Prospect - Customer" field is filled in THEN a 10 will automatically be entered in the corresponding "Pts" field

IF a "New Quote #" field is filled in THEN a 5 will automatically be entered in the correspondng "Pts" field

Sample Form below for visual

Capture.JPG

TOPICS
PDF forms

Views

134.6K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Aug 05, 2016 Aug 05, 2016

You can use something like this as the custom calculation script of the Pts field:

event.value = (this.getField("NameOfOtherField").valueAsString=="") ? "" : 3;

Votes

Translate

Translate
replies 102 Replies 102
New Here ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

try67,

I am working on a form and this is my very first time.  I created the pdf from excel.  I have a field that I want to calculate the average value (overall rating) of a number of other required fields (individual ratings).  I then have a field that I would like to show the rating description based on the overall rating score.  I have no clue how to create the calculation field or the "if/then" field.  Am I too green for your help 🙂

Rating Descriptions formula from excel

=IF(Q14<1, "Not Met",IF(Q14<1.75, "Approaching",IF(Q14<2.75, "Solid Performance",IF(Q14<3.75, "Exceeds Expectations"))))

Thank you

Votes

Translate

Translate

Report

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 ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

Yep that's pretty much Greek to me.  Thanks anyway 🙂

Votes

Translate

Translate

Report

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 ,
Aug 18, 2017 Aug 18, 2017

Copy link to clipboard

Copied

I am trying to make a form so that when a user types in their name in a preliminary field, it is auto-populated to a read only field below (the typed name before the signature line).  I know you can duplicate a field result by naming the subsequent field the same as the original, but if I choose "read only" on the second field it also alters the properties of the first field and I cannot enter the info in the first place.

I am also trying to make this second field "not look like a fillable field" (i.e. no box outline and shading) but still fill in when the original field is completed.


Any thoughts?

Votes

Translate

Translate

Report

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 ,
Aug 18, 2017 Aug 18, 2017

Copy link to clipboard

Copied

Let's say you want to copy the value of field A to field B. Use this code as the custom calculation script of B:

event.value = this.getField("A").valueAsString;

You can then set field B to be read-only and any other appearance properties you want, as it's not "bound" to field A.

Votes

Translate

Translate

Report

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 ,
Aug 18, 2017 Aug 18, 2017

Copy link to clipboard

Copied

Perfect-

Thank you.  I was trying to discern that from earlier comments above but I didn't include the ".valueAsString."

Appreciate the help!

Votes

Translate

Translate

Report

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 ,
Dec 02, 2017 Dec 02, 2017

Copy link to clipboard

Copied

Please I need help. I want a read only text  field A. Then I want to create a button in which they can actually click to pop up a text box. And when they fill in the pop up textbook,  it will automatically  replace the text in the read only text field A.  Please how do I go about it...

I need the javascript for this operation.

Thank you.

Votes

Translate

Translate

Report

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 ,
Dec 02, 2017 Dec 02, 2017

Copy link to clipboard

Copied

You should ask this question on a new thread.

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

Votes

Translate

Translate

Report

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 ,
Sep 24, 2019 Sep 24, 2019

Copy link to clipboard

Copied

Thanks for sharing Try67! I have a follow-up question to what was posted below. I used the the code above in the custom calculation script, but I am having trouble getting it to work on my spawned page.

 

For example, I have First Name on Page 1 and the custom calculation on the First Name field on page 2. This works on page 2, but I have a button on Page 2 that spawns a new Page 1 and 2. The First Name on the new Page 4 is still pulling the first name on Page 1. Is there a way to fix this?  

 

If it helps, I am using the following code to spawn new pages:

 

var NextPageIndex = this.pageNum + 1;
{
var a = this.getTemplate("Page 2");
a.spawn(NextPageIndex, true, false);
var PageName = "P"+NextPageIndex;
this.resetForm(PageName);

var a = this.getTemplate("Page 1");
a.spawn(NextPageIndex, true, false);
var PageName = "P"+NextPageIndex;
this.resetForm(PageName);
}

Votes

Translate

Translate

Report

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 ,
Sep 10, 2017 Sep 10, 2017

Copy link to clipboard

Copied

I have a similar question with a text field document in InDesign. Instead of going through and changing the name on every page, I was hoping there was a form I could fill in and the names and information in the document would change depending on what I typed into the form. The names and information would change with new customers etc so this isn't something I could set up as a mail merge.

Also having trouble about where to put the code etc? Thanks!

Votes

Translate

Translate

Report

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 ,
Mar 07, 2018 Mar 07, 2018

Copy link to clipboard

Copied

hi,

what if i need the Text field to be populated with a letter related to what was chosen in a dropdown field?

Ex

helicopter1          =  A

helicopter2          = B

helicopter3          = C

Votes

Translate

Translate

Report

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 ,
Mar 07, 2018 Mar 07, 2018

Copy link to clipboard

Copied

Put the letter as the export value of each option and then you could use a simple script to do it.

Votes

Translate

Translate

Report

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 ,
Mar 07, 2018 Mar 07, 2018

Copy link to clipboard

Copied

what would that script be?

Votes

Translate

Translate

Report

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 ,
Mar 07, 2018 Mar 07, 2018

Copy link to clipboard

Copied

See my reply to the thread you opened...

Votes

Translate

Translate

Report

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 ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

Hey all,

I'm building a proposal/quote template in Acrobat. I have a multi-picklist of "Items" (field actually called "Item Description" in acrobat) . I'd like the Item's pricing to autofill in the "Unit Price" once it's selected from the picklist. Can anyone help?

ex: select item "Blue Paperclips" from multi-picklist and $2.50 is automatically filled in the "Unit Price" column.

Votes

Translate

Translate

Report

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 ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

As the custom calculation script of the Unit Price field enter this code:

event.value = this.getField("Dropdown field name").valueAsString;

Adjust the field name as needed, of course.

Votes

Translate

Translate

Report

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 ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

Hey try67,

The only thing I needed to change in your line of code was to add my dropdown options in between the quotes, right? I have 31 options in the picklist so I copy and pasted this code 31x and changed the field names in each of the 31 pastes (line breaks after each of the 31 pasted codes). The code wouldn't pull the value (which was assign in the picklist value).

I also tried just pasting the code once and replacing "Dropdown field name" with the name of the field (not the picklist options). Neither worked, what am I doing wrong? Should I not have included the quotes in the Dropdown field names? No line breaks in the pasted codes?

Thank you for your speedy reply,@try67.

Votes

Translate

Translate

Report

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 ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

No, you don't need to insert the options in the code. They are taken from the field's value. All you need to do is replace "Dropdown field name" with the actual name of your field, WITH the quotes.

Votes

Translate

Translate

Report

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
Explorer ,
Jul 14, 2018 Jul 14, 2018

Copy link to clipboard

Copied

@try67 Your code for the dropdown menu was so helpful. Thank you so much!

Votes

Translate

Translate

Report

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 ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

I have a time sheet that i'm attempting to customize.  i have a document JavaScript that auto populates the shift for two weeks depending on the employee selection in the drop down box.  What i would also like to do is if any data is in the SICK column it would automatically put the word SICK in the Shift column.  I did get this to work by adding this custom calculation to the SHIFTSUN field.

event.value = (this.getField("SICKSUN").valueAsString=="") ? "" : "SICK";   

My issue is this custom calculation overrides the Document level Javascript and if that custom calculation is behind that field the field is blank regardless if anything is in the SICK field or not.. 

Incidently i would also like to do the same thing for the Vacation, Personal, Wellness fields, if any data is in those fields the Shift field would show  VAC, PERS, WELL.  but i'm not sure how to do this without one overriding the other.  I attempted to add a line for VAC in the same custom calculation field as the above code, but that just overrode the SICK code and it didn't work.  

I admit that i'm extremely new to this and i hope i explained this ok.

i will include a couple of screen shots if those help at all.

temp.png

This is after i add that SICK custom calculation in the shift field.

before sick.png

When i put the -8 under the sick column it does change the shift field to SICK.

aftersick.png

Votes

Translate

Translate

Report

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 ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

You need to change the field calculation order so that the "SHIFTSUN" field is calculated after the "SICKSUN" field.

Votes

Translate

Translate

Report

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 ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

I'm sorry, but i'm still learning.  How do i do that?  currently the SHIFTSUN field is populated from a Document JavaScript.

Votes

Translate

Translate

Report

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 ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

What do you mean? What triggers that doc-level script?

Votes

Translate

Translate

Report

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 ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

Hey try67,
I have an issue trying to multiply this part on picture below of my PDF file. Number of copies depends on number that I enter in field ''Number''. I need the whole thing including the border lines of the text box.

Screen Shot 2018-07-02 at 1.38.26 PM.png

Also need to get initials of all participants (depending on the number) in the next field (separate field for each participant) which will give me a,b,c (separated whit comas) and their initials.

ex. Initials: BKL

      Box that are checked are a,c,e,f,g

      Result: a,c,e,f,g:BKL

Can you help me?

Thanks for your speedy reply, @try67.

Votes

Translate

Translate

Report

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 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

You would need to place this section on its own page, define that page as a Template and then spawn new copies of it as necessary, making sure to specify that the fields be renamed on each copy.

Votes

Translate

Translate

Report

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