I have a form called myform with a listbox called combounit. How do I make
it change the element selected
in combounit?
I have tried:
document.myform.combounit.options[0].selected = true;
and
document.myform.combounit.selectedIndex = 0;
but none of them work.
Regards,
Jan Nordgreen
Try the following:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Select Animation</title>
<script type="text/javascript">
//<![CDATA[
<!--
var s;
var i = 0;
function test(){
i++;
if (i >= 7) i = 0;
s.selectedIndex = i;
}
window.onload = function(){
s = document.getElementById("myselect");
window.setInterval("test()", 500);
}
//-->
//]]>
</script>
</head>
<body>
<select size="7" id="myselect">
<option value="1" selected>option1</option>
<option value="2">option2</option>
<option value="3">option3</option>
<option value="4">option4</option>
<option value="5">option5</option>
<option value="6">option6</option>
<option value="7">option7</option>
</select>
</body>
</html>