...

View Full Version : selection in <select> tag



irfan_haider
08-24-2002, 06:20 AM
Dear friends
I have a problem and I need Your Help
let suppose we have a <SELECT> dropdown list and in which we have 5 options. If in javascript function we pass option no. how can we make that option selected.

beetle
08-24-2002, 06:51 AM
<script>
function setIndex(index, selID) {
var obj = document.getElementById(selID);
obj.selectedIndex = index;
}
</script>

(...HTML...)

<span onClick="setIndex(3,'demo');">Set to 3</span>
<select id="demo">
<option value="blah1">blah1</option>
<option value="blah2">blah2</option>
<option value="blah3">blah3</option>
<option value="blah4">blah4</option>
</select>

irfan_haider
08-24-2002, 07:45 AM
THANKS BEETLE
IT WORKS
THANKS A LOT



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum