Expand my Community achievements bar.

Populate text fields using drop-down list

Avatar

Former Community Member
Hi,



I need help to populate 4-5 text fields using a drop down menu.



For example,



You select a product, PRINTER (this is from the drop down menu)



THEN IT WILL POPULATE 4-5 TEXT FIELDS BELOW IT:



textfield1: Laser

textfield2: Model 123

textfield3: Toner 1

textfield4: Speed 1



So what's populated will be assigned to the drop down menu option 'PRINTER' - so if I select for example, TV from the drop down menu it will populate the text fields that have been assigned to "TV".



Please let me know how this can be down.



Thanks!!
6 Replies

Avatar

Former Community Member
If I select printer from the drop down where does the - Laser, Model 123, Toner 1, Speed 1 - come from? Are you going to hard code it?

Avatar

Former Community Member
I prefer if its hard coded (because this is going to be shared on a server, so for compatibility it would be better if everyone had the same data)



However, if its easy, faster and better to create a database (*mdb) and make a data-connection, then I am open to any any help I can get.

Avatar

Former Community Member
Hard coing would be the easiest way. You could use a switch statement on the exit event of the dropdown (the javascript equivalent of a case statement). It would look something like this:



switch(DropDownList1.rawValue){



case "Printer":

TextField1.rawValue = "HP Laser Jet";

TextField2.rawValue = "Version 5";

break;

case "Computer":

TextField1.rawValue = "Dell Laptop";

TextField2.rawValue = "Iperion";

break;

case "Desk":

TextField1.rawValue = "Mahogany";

TextField2.rawValue = "Red";

break;

}

Avatar

Former Community Member
Hi,



I have created the document, but i'm getting a 'script failed' error.



i "Error: function 'switch' on line 2, column 30 is unknown.



b EXACTLY WHAT I HAVE DONE:



b 1/ created a new document



b 2/ insert drop-down list from object library

> added 'Printer', 'Computer', 'Desk' value to the list

> in script editor: changed SHOW to 'exit', and pasted the code you provided



b 3/ insert 2 text fields

> renamed the name under the 'binding' tab to TextField1 and TextField2



When I go to preview PDF i get the script error.

Avatar

Former Community Member
Can I attach the file here somewhere? or send you an email to have a look please??

Avatar

Former Community Member
Did you change the script to javascript?



If you need to, send it to livecycle8@gmail.com