PHP beginner |
|
Even wat info gezocht op de MSDN site. Het volgende zou moeten werken:
<select id="test">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<script language="javascript">
selectOption('test', 2);
function selectOption(id, value)
{
var objSelect = document.getElementById(id);
var arrOptions = objSelect.options;
for(var i = 0; i < arrOptions.length; i++)
{
arrOptions[i].selected = false;
if(arrOptions[i].value == value)
{
arrOptions[i].selected = true;
}
}
}
</script>
<select id="test"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <script language="javascript"> selectOption('test', 2); function selectOption(id, value) { var objSelect = document.getElementById(id); var arrOptions = objSelect.options; for(var i = 0; i < arrOptions.length; i++) { arrOptions[i].selected = false; if(arrOptions[i].value == value) { arrOptions[i].selected = true; } } } </script>
|