Total Pageviews

Monday, 29 July 2013

Livecycle Designer: Populate Text Field Based On Drop-Down List Selection - Javascript code

Let's say the text field is named "TextField1" and that you've 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 your drop down list's Change event, you could use the following script (in JavaScript): 


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

  case "1": // car purchase
    TextField1.rawValue = "Basic features:\n- frame\n- wheels\n- glass";
    break;
  case "2": // other purchase
    TextField1.rawValue = "Basic features..."
    break;
  default: // unknown value -- do nothing
    break;
}

1 comment: