cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1513
Views
5
Helpful
2
Replies

set option list with javascript

david.hout
Level 1
Level 1

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 2

mpetra
Cisco Employee
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.

I see - that makes sense - thanks!

Review Cisco Networking for a $25 gift card