Expand my Community achievements bar.

SOLVED

Select from a dropdown list and specified item values appear in textfield

Avatar

Level 3

I need for a to be able to select from a dropdown list and specified item values appear in textfield.

For example if I select Amy

If I select Bob

If  I select Jane

Amy

Bob

Jane (I would like the list to appear as shown)

I have associated a value to each item in the drop down list so that the selection is easy to compare in order to determine which initial (default) value to set in the text field. In my drop down list's Change event, I have the following:

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

switch (sNewSel)

{

  case "1": //  Amy

     TextField1.rawValue = "Amy \n";

     break;

switch (sNewSel)

{

  case "2": //  Bob

     TextField1.rawValue = "Bob \n";

     break;

Of course this is not working only name is showing at a time. Please help!

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 5

Not sure what the code is suppose to do, but you basically want to add the name from the dropdown appending onto the current value of the textfield? Why not use the dropdownlist display value directly? For example on the change event :

if ( TextField1.rawValue == null )

    TextField1.rawValue = xfa.event.newText;

else

    TextField1.rawValue += ( "\n" + xfa.event.newText );

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

Not sure what the code is suppose to do, but you basically want to add the name from the dropdown appending onto the current value of the textfield? Why not use the dropdownlist display value directly? For example on the change event :

if ( TextField1.rawValue == null )

    TextField1.rawValue = xfa.event.newText;

else

    TextField1.rawValue += ( "\n" + xfa.event.newText );

Avatar

Level 3

That will work!

Thanks for your help