[Javascript] Pre-selecting a Select Box multiple items using a convenient function
DEV
dev at qroute.net
Thu Jun 19 14:07:13 CDT 2003
Is there nice javascript function outthere to go thru the options of a
select box and setting those options to "SELECTED" where a match occurs ?
Something like this
function SetSelect (selObject,values)
{
/*
assuming values are comma seperated, we can put "values" into an array using
split
and then cycle thru the select options and see if any of the items in
"values" has a one tp one match if so, we set the selObject's selected
attribute on for that option
Example if the select box is a US states select,
a call like this <script>SetSelect
(window.document.all.selStates,"California,New York")</script> should make
the California and NewYork highlighted in the multiple select
}
Once I figure this out, I'd like to extend the same concept to radio optns
and check boxes as well with similar functions.
If you can kindly assist me on this, I's appreciate it.
Regards,
More information about the Javascript
mailing list