Og en lille bug fix sat ind på onsubmit, så knappen ikke
uheldigvis står til disabled, når man trykker på submit ...
(undskyld de mange posts... men jeg så først fejlene bagefter
og ville rette dem - desværre var der en del fejl ...)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Ingen titel</title>
<script type="text/javascript">
tn="";tn2="";tn3="";
window.onload=function(){
tn=document.getElementById("opts_1");
tn2=document.forms.formnavn.options_1;
tnt=tn2.offsetTop;tnl=tn2.offsetLeft;
tnx=tn2;while(tnx=tnx.offsetParent){
tnt+=tnx.offsetTop;
tnl+=tnx.offsetLeft;
}
tn.style.position="absolute";
tn.style.top=tnt+"px";
tn.style.left=tnl+"px";
tnapp=tn2.cloneNode(true);
tnapp.onclick=function(){showhideopts(1);}
tnapp.setAttribute("id","optsh_1");
tnapp.setAttribute("name","optsh_1");
tnapp.setAttribute("size",tnapp.childNodes.length);
tn.removeChild(tn.childNodes[0]);
tn.appendChild(tnapp);
tn3=document.getElementById("optsh_1");
showhideopts(0);
}
function showhideopts(type){
tn.style.display=(type==0)?"block":"none";
tn2.disabled=(type==0)?true:false;
document.body.focus();
tn2.selectedIndex=tn3.selectedIndex;
}
</script></head>
<body>
<form name="formnavn" style="display:inline;" onsubmit="showhideopts(1);">
<select name="options_1" onmousedown="showhideopts(0);"><option>Test 1</option><option>Test 2</option><option>Test 3</option><option>Test 4</option></select>
<input type="submit" value="Afsend">
</form>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<div id="opts_1" style="display:none;">a</div>
</body></html>