You have to loop through all the options and test each one until you find
it, this example assumes you're testing against text value:
function setListbox(name, value, caseSensitive)
{
var oList = document.forms['abc'].elements[name];
var sTestValue = (caseSensitive ? value : value.toLowerCase());
var sListValue;
for (var i = 0; i < oList.options.length; i++)
{
sListValue = (caseSensitive ? oList.options[i].text :
oList.options[i].text.toLowerCase()); //change text to value if you wish to
compare by value of listbox.
if (sListValue == sTestValue)
{
oList.selectedIndex = i;
break;
}
}
}
setListbox("Country", "Canada", true);
untested code provided by joe, dont know how that is, but anyway thanks
Thursday, October 06, 2005
javascript "loop through all the options and test each one until"
at 3:09 PM Posted by roni schuetz
Subscribe to:
Post Comments (Atom)
Shared Cache - .Net Caching made easy
All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.
1 comment:
Thanks !
Post a Comment