Expand my Community achievements bar.

Populate Text Field Based On Drop-Down List Selection

Avatar

Former Community Member
I'm trying to set up a form so that a text field will populate with default text (that could later be edited by the end user) based on a users previous drop-down selection.



For example:



The end user is putting together a proposal for a client and is able to choose the type of proposal or service from a drop-down list. Once the user makes a selection from the drop-down list a text field is populated with default text describing the service.



The only catch is that the end user would need to be able to edit the default text. An example would be if an individual purchased a car but all the specific features and/or accessories could be added into the default text as necessary based on the purchasers desired upgrades. The common or universal features of the car would, however, show up as the default text.



Would this scenario be possible through the use of XML? Any tips on how I can accomplish this would be much appreciated.
26 Replies

Avatar

Former Community Member
I am not sure this is what you are looking for but this is the script behind the drop down on change event and InsertNote1 is the text field being populated. The text field is also set to Calculated - Allow User Override.



var sNewSel = this.boundItem(xfa.event.newText);

var bEnableTextField = true;



switch (sNewSel)

{

case "1": // Option 1

InsertNote1.rawValue = "Text if option 1 is selected.";

break;



case "2": // Option 2

InsertNote1.rawValue = "Text if option 2 is selected."

break;



case "3": // Option 3

InsertNote1.rawValue = "Text if option 3 is selected."

break;



case "4": // Option 4

InsertNote1.rawValue = "Text if option 4 is selected."

break;



case "5": // Option 5

InsertNote1.rawValue = "Text if option 5 is selected."

break;



case "6": // Option 6

InsertNote1.rawValue = "Text if option 6 is selected."

break;



case "7": // Option 7

InsertNote1.rawValue = "Text if option 7 is selected."

break;



case "8": // Option 8

InsertNote1.rawValue = "Text if option 8 is selected."

break;



default: // unknown value -- do nothing

bEnableTextField = false;

break;

}



if (bEnableTextField)

{

InsertNote1.access = "open"; // enable field

InsertNote1.caption.font.fill.color.value = "0,0,0"; // set caption to black

}

Avatar

Former Community Member
I am trying to populate text fields with the same information, such as the name, address, and phone number. I want to know if there is way that I can do so, without having to use any outside coding. I don't need to populate complex information, just the basic. I guess my main purpose is to have that simple information populate throughout a form without having re-type such information throughout my 4-6page forms. Leaving me with less room for error.

Avatar

Level 7
If you are going to set another field's value from a combo box or list you need to use some form a scripting.

Avatar

Former Community Member
Hi how to generate the text field with the selection of an item in the combo box please help me if any one knows

Avatar

Former Community Member
Stefan,



I used your example in my table, which worked for the first row. However, I have a repeatable table with add and delete row buttons and the drop down only populates the first row.



So, if I use the first drop down on the first row, it populates the first text field in the first row just fine. However, when I use the drop down on the next row, the first row gets updated instead of the second row text field. How do I tweak the nomenclature so that it knows to correspond to the same row?



Dave

Avatar

Level 1

I am Working on a text field to, creating the form is no problem with a little Script.Right now Im just using an easy Drop Down Menu Generator.

http://www.javascriptsandmore.com/drop-down-menu-generator-software.html