Hi Guys,
I've hit a wall, im trying to create a function to make an option in a <select> box selected when given its value, rather than its index. I cant seem to figure out how to loop through each value for each option.
This is what I have so far, but its not correct...
"selObj" is the <select> as an object
Any help is much apprieciated1
Thanks
Andy
I've hit a wall, im trying to create a function to make an option in a <select> box selected when given its value, rather than its index. I cant seem to figure out how to loop through each value for each option.
This is what I have so far, but its not correct...
"selObj" is the <select> as an object
Code:
function selectOptionByValue(selObj, value){
for (options in selObj.options){
if (options.value == value){
options.selected = true;
break;
}
}
Any help is much apprieciated1
Thanks
Andy
Comment