Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

set option list with javascript

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

2 REPLIES
Cisco Employee

set option list with javascript

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.

Community Member

set option list with javascript

I see - that makes sense - thanks!

683
Views
5
Helpful
2
Replies
CreatePlease to create content