Hi,
Try this sample code for the select box named "sel"
Provisionally, the width of the select box is 10*(length of the text). You may define a different factor as per the font
The Triggering events should be onChange, onFocus and onBlur
<html>
<script>
function fnChangeLength(){
len = document.forms[0].sel.opti
width = len*10
document.forms[0].sel.styl
}
function fnResetLength(){
document.forms[0].sel.styl
}
</script>
<body >
<form name="frm1">
<span id="output" name="output" style="width: 360px; color: red;" ></span>
<br>
<select name="sel" id="sel" onFocus="fnChangeLength()"
<option value="0">AAAAA</option>
<option value="1">AAAAAAAAAAA</opt
<option value="2">AAAAAAAAAAAAAAAA
</select>
<input type="text" name="text1" id="text"/>
</form>
</body >
</html>
Main Topics
Browse All Topics





by: VirusMinusPosted on 2007-03-13 at 03:47:57ID: 18708937
try this;
'<% = maxOptionWidth %>px !important';" 125px';">
<select name="select"
style="width:125px;"
onclick="this.style.width=
onblur="this.style.width='