Hi
I would like to set the values of the options in a dropdown list with a javascript when the page loads. I have tried with:
<script language="JavaScript">
function ini(){
dimg80 = new Array(2)
dimg80[0] =new Array("6 mm","8 mm","10 mm","12 mm","14 mm","16 mm","20 mm","24 mm","30 mm","36 mm","42 mm","48 mm"
dimg80[1] =new Array(0.1,0.2,0.25,0.4,0.75,1,1.5,2,3,4,6,8)
for (var i = 0; i < dimg80[1].length; i++) {
dimensjon.options=new Option(dimg80[0],dimg80[1]);
}
}
</javascript>
<body onload="ini()>
<form>
<select name="dimensjon>
</select>
</form>
</body>
I got this error: 'dimensjon' is undefined. I think this happend because the script is loaded before the hole page are loaded. How can i set the values for dimensjon.option[] with a javascript onload?
Jørn Arild Andenæs
jaa@jaa.no
I would like to set the values of the options in a dropdown list with a javascript when the page loads. I have tried with:
<script language="JavaScript">
function ini(){
dimg80 = new Array(2)
dimg80[0] =new Array("6 mm","8 mm","10 mm","12 mm","14 mm","16 mm","20 mm","24 mm","30 mm","36 mm","42 mm","48 mm"
dimg80[1] =new Array(0.1,0.2,0.25,0.4,0.75,1,1.5,2,3,4,6,8)
for (var i = 0; i < dimg80[1].length; i++) {
dimensjon.options=new Option(dimg80[0],dimg80[1]);
}
}
</javascript>
<body onload="ini()>
<form>
<select name="dimensjon>
</select>
</form>
</body>
I got this error: 'dimensjon' is undefined. I think this happend because the script is loaded before the hole page are loaded. How can i set the values for dimensjon.option[] with a javascript onload?
Jørn Arild Andenæs
jaa@jaa.no