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

automatic drop down

Community Beginner ,
Sep 25, 2018 Sep 25, 2018

Hello all,

I see this question has been asked several times but seems like non of the scripts work for my PDF document or I am very begginer level.

What I am trying to achieve is that I have two drop-down menus, and whenever I pick an item from the first drop down, I want the other drop down to give automatic answers based on the item picked from the first drop down.

So to give you an idea, we have Resignation in the first drop box (called Transaction), and I want the person who picked resignation to have " 14 weeks, 12 weeks, 10 weeks option available right away in the second drop down (called Transaction 2).

I have created both drop downs and was using this javascripcode:

  1. switch (event.value) { 
  2.     case "Transaction"
  3.         this.getField("Transaction 2").setItems(["14 weeks,12 weeks,10 weeks]); 
  4.         break

But when I close javascript - seems like it is not working.Anny advice will be highly appreciated!!!

Thank you!

TOPICS
PDF forms
2.2K
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 26, 2018 Sep 26, 2018

Your field is not named "Transaction". They are named "Dropdown3" and "Dropdown4". Go to Prepare Form mode and look at what's written on top of them, as well as what's listed in the Fields List panel on the right. The text next to the fields is irrelevant.

When I added that line of code it worked fine for me. The values of "Dropdown4" changed as soon as I made a change in the selected value of "Dropdown3".

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 ,
Sep 25, 2018 Sep 25, 2018

You didn't close the string properly in line #3. Also, each item needs to be a separate string, so use this:

setItems(["14 weeks","12 weeks","10 weeks"])

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 ,
Sep 25, 2018 Sep 25, 2018

Hey there,

I appreciate your response - I will try thta and let you know.

Also, do I create this script in "Validate" or "Action" , cause whole this time I was trying to do it in "Actions"

thanks again!

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
LEGEND ,
Sep 25, 2018 Sep 25, 2018

It should be a validate script, and the complete one could look like:

// Custom Validate

var aItems;  // Array of items to populate dropdown with

switch (event.value) {

case "Transaction" :

    aItems = ["14 weeks", "12 weeks", "10 weeks"];

    break;

case "Item 2" :

    aItems = ["Item 1", "Item 2", "Item 3"];

    break;

case "Item 3" :   

    aItems = ["Item 4", "Item 5", "Item 6", "Item 7"];

    break;

default :

    aItems = []; // Clear dropdown

    break;

}

getField("Transaction 2").setItems(aItems);

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 ,
Sep 26, 2018 Sep 26, 2018

Hey George, Thank you.

So I have two fields Transaction Type (that includes Resigantion, New Hire Etc) and the second drop box called "Transaction 2" that has corresponding answers (for example for Resignation it should give me 14, 12, 10 weeks).

I am surprised that i do not have to include "Transaction2" in the script?

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
Community Beginner ,
Sep 26, 2018 Sep 26, 2018

That's my script - it still not working

// Custom Validate

var aItems;  // Array of items to populate dropdown with

switch (event.value) {

case "Resignation" :

    aItems = ["Transfer to", "Transfer to  LIS", "Resignation (leaving RIS)"];

    break;

case "New Hire" :

    aItems = ["Brand New Hire", "Transfer from RIS", "Transfer from RISO"];

    break;

case "Pregnancy" :  

    aItems = ["3", "2 months", "others/specify"];

    break;

case "Parental ":

   aItems = ["17 weeks", "others/specify"];

default :

    aItems = []; // Clear dropdown

    break;

}

getField("Transaction 2").setItems(aItems);

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 ,
Sep 26, 2018 Sep 26, 2018

"It's not working" is not very helpful... In what way is it not working? Is there an error message in the JS Console when you use it? Does it apply the wrong values? No values at all? Please provide details. It would also be helpful if you could share the actual file with us (via Dropbox, Google Drive, Adobe Send & Track, etc.).

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 ,
Sep 26, 2018 Sep 26, 2018

Hello ty67,

I would love to share but unfortunately it is strictly confidential

So the code I am inputting for Validate is this:

"switch (event.value) {

    case "Transaction Type":

        this.getField("New Hire").setItems(["Brand New Hire","Transfer from LRIO","Transfer from RIOS"]);

        break;

}

is there anything I am missing?

And when i am say it is not working, it does not give me an error message - everything seems OK - however when I close it - the script does not apply to the document.

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
LEGEND ,
Sep 26, 2018 Sep 26, 2018

You said you tried one script that looks complete, but your latest seems to be back to something like your original, and it's incomplete. It's hard to keep track with what you're doing. With your latest, you have a double-quote mark at the beginning, which shouldn't be there.

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 ,
Sep 26, 2018 Sep 26, 2018

My apologies _-i was trying to do both versions - but none of them worked.

So, i removed the quotation mark and it is still not working. You mentioned my first script looks fine - any reason why it might not be working with the right script?
Really sorry if I was not clear enough.

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
Community Expert ,
Sep 26, 2018 Sep 26, 2018

Move just those fields to a blank file and share it with us, please. Without seeing it it's very hard to help you with these issues...

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 ,
Sep 26, 2018 Sep 26, 2018

Hey,

I created a separate PDF, but nor sure how can I share file here. Any advise?

Will screenshot be sufficient?

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
Community Expert ,
Sep 26, 2018 Sep 26, 2018

Upload it to one of the sites I mentioned, generate a public sharing link and post it here.

No, screenshots are not good enough.

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 ,
Sep 26, 2018 Sep 26, 2018
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 ,
Sep 26, 2018 Sep 26, 2018

That link doesn't work. If you prefer you can email it to me directly to try6767 at gmail.com .

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 ,
Sep 26, 2018 Sep 26, 2018

Sent it 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 ,
Sep 26, 2018 Sep 26, 2018

Yes. Your script is not exactly what you posted here... You're not applying the values to the second field at all.

Add this line to the end of your current code:

this.getField("Dropdown4").setItems(aItems);

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 ,
Sep 26, 2018 Sep 26, 2018

I will definitely add that - the reason is a bit different because I could not sent you the form or the values due to confidentiality.

two questions:

why this getfield "dropdown4" if I do not have any value with the name "DropDown4" as well as name of my dropdowns is Transaction?

is there anything else I need to add? other than that

And for sure cant thank you enough for assisting me with this - it is VERY important for me:(

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 ,
Sep 26, 2018 Sep 26, 2018

Your field is not named "Transaction". They are named "Dropdown3" and "Dropdown4". Go to Prepare Form mode and look at what's written on top of them, as well as what's listed in the Fields List panel on the right. The text next to the fields is irrelevant.

When I added that line of code it worked fine for me. The values of "Dropdown4" changed as soon as I made a change in the selected value of "Dropdown3".

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 ,
Sep 26, 2018 Sep 26, 2018

Oh wow  - I will check it tomorrow - but I think now I know whats the problem is.

I was using name outside the box "transaction" as opposed to the "text on the drop down box"

WOW! If that works - I will be grateful to the sky and back!!

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 ,
Sep 27, 2018 Sep 27, 2018

Hello try,

So it FINALLY WORKED!!! Can't thank you enough!

However Now I have different problem, after moving some of the fields on the form when I submit the form it sends it to the e-mail address that was previously used. So instead of sending to Jen Doe it sends to Den Doe (even when I update the script

// Before sending the data, make sure that all required

// fields are valid

//

//  The "Ex1ValidFields" fucntion is located in the document script

//  If you copy this button action then you will also need to delete

//  this first if statement or copy the "Ex1ValidFields()"

//  fucntion and modify it to work with your form.

//

    // This is the form return email, It’s hardcoded

   // so that the form is always returned to the same address

   // Change address on your form

   var cToAddr = "Jen.Doe@gmail.com";

   // Set the subject line

   var cSubLine = " Form   -  "

                +

this.getField("Employee First Name").value + " "

                + this.getField("Employee Last Name").value + " - "

                + this.getField("Transaction ").value + " "

   //  Set the body text for the email message

   var cBody = "Hello  Jill,\n" +

               "Please see the attachedt form for "                 + this.getField("Employee First Name").value + " "

                + this.getField("Employee Last Name").value + " - "

                + this.getField("Transaction Type").value + ". \n" 

               

               +

                 

           "Thank you,\n "

   

       

   // Send the entire PDF as a file attachment on an e-mail

   this.mailDoc({bUI:true, cTo: cToAddr,

                  cSubject: cSubLine, cMsg: cBody});

Even when I give that script to "Submit" button javascript it still send it to the e-mail that has been previosuly attached to this form (e.g. Den Doe) How do i change so it goes again to Jen Doe ??

If its possible if not, I will try to figure something out

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 ,
Sep 27, 2018 Sep 27, 2018

This is a different issue. Maybe start a new thread regarding it, and also please post another sample file that demonstrates it.

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 ,
Sep 27, 2018 Sep 27, 2018

TThank you try a BUUNCH!!!

Teh new thread is here:

E-mail PDF differennt values

Appreciate any inpuit!!!

Thnks a lot!

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 ,
Sep 27, 2018 Sep 27, 2018

No worries Try67- I figured the problem with submit button- I had to delete the submit button and and re-create scriot.

Cant thank you enough for all the help, REALLY! Your patience is out of everything

SO automatic works great, however when I want the other field in first Dropdown to bring me 0 results, which code should I use?

  1. switch (event.value) {
  2.     case "Transaction":
  3.         this.getField("Dropdown4").setItems([" ");
  4.         break;

this.getField("Dropdown4").setItems(aItems);

But it does not bring me "space" or "zero results" -

to be more precise so great when I choose "resignation" it brings me '2 days" resulys, but when I change to "resigantion 2" I want it to automatically change to "blank?

Possible?

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 ,
Sep 27, 2018 Sep 27, 2018

Simply define aItems as having one blank item, like this:

aItems = [""];

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