×

Warning message

  • Cisco Support Forums is in Read Only mode while the site is being migrated.
  • Cisco Support Forums is in Read Only mode while the site is being migrated.

set option list with javascript

Unanswered Question
Jun 22nd, 2012
User Badges:

Is it possible to set the option list for a select via javascript?  I see that you can select an option with


serviceForm.<form name>.<field name>.setSelection(["option1");


but I'm curious if you can also populate the list dynamically with the javascript api

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
mpetra Mon, 06/25/2012 - 20:18
User Badges:
  • Cisco Employee,

There are helper functions that are defined within the isfcode libraries, but I don't think it's usually deployed at customers.


There are not any "core" ISF functions to use for this (serviceForm....). What you have to use instead is just raw javascript.


A few samples:


//# elements

document.getElementById("Dictionary.FieldName").options.length;


//value of index i

document.getElementById("Dictionary.FieldName").options[i].value;


//use this in a loop and set the values of the drop down.

document.getElementById("Dictionary.FieldName").options[i] = new Option(newstrValue,newValue,false,false);


Usually the dropdown is either known in advance or set with a data retrieval rule. You should re-examine the use case and see if you can avoid using the javascript method.

Actions

This Discussion