Yes this is possible. The below should work in IE, Firefox,
Netscape and Opera
Code:
<HTML>
<HEAD>
<TITLE>AutomaticallySelectingOption.htm</TITLE>
<SCRIPT>
function selectit()
{
document.getElementById('D1').options[1].selected=true
}
</SCRIPT>
</HEAD>
<BODY onload="selectit()">
<SELECT size="1" id="D1">
<option value="01">-- Oils + Acrylics</option>
<option value="02">-- Water Colours</option>
<option value="03">-- Pastels</option></SELECT>
<P>-- Water Colours was automatically selected.</P>
</BODY>
</HTML>
The above uses the option collection of the element
to automatically select from the drop-down list.
Another way is to use the value of the select
element:
Code:
document.getElementById('D1').value='02'
Change the above to this and get the same result.
DEMO