options[n] has no properties
hvorfoer siger den form.options[n] has no properties???function tjekform(form){
for(var n = 0; form.length; n++){
antal = 0;
alert(antal);
if(form.options[n].selected == true){
antal++;
}
}
if(antal == 0){
document.all.fejl.innerHTML = "<br>Du skal vælge mindst en kategori til billedet/billederne";
setTimeout("document.getElementById('fejl').innerHTML ='';", 5000);
document.getElementById("kategorier").focus();
return;
}else{
alert(antal);
return;
}
}
.......................
<form action="" method="post" enctype="multipart/form-data" name="upload" id="upload">
<select id="kategorier" name="kategorier[]" size="50" multiple style="height:130px; width:150px " class="input_blur" onFocus=" this.className='input_focus'" onBlur=" this.className='input_blur'">
<option value="39" >bla bla</option>
<option value="36" >dette er en test</option>
<option value="28" selected >Idræt</option>
<option value="30" selected >Sport</option>
<option value="57" >test</option>
</select>
<input name="uploadknap" onClick="tjekform(document.getElementById('kategorier'));" type="button" value="Ret Info" class="input_knap" onMouseover=" this.className='input_knap2'" onMouseout=" this.className='input_knap'" style="width:100px " >
</form>