Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

option list sizing

Status
Not open for further replies.

blueindian1

Programmer
Apr 24, 2001
150
US
Hello,

Is it possible to set a width for an option list such that it is only X wide regardless of the size of the options?

What I need is an option list that is 10 characters wide, but can contain options that are up to 30 characters wide. And I need to see the whole value for the option once the list is dropped down

Thanks

rich
 
Hi rich,

Try this.
It works for IE.
Works not for NN4.7 (I can't test NN6 here).

<script language=&quot;javascript&quot;>
function changeWidth()
{
document.MyForm.selectboxname.style.width = 300;
}

function resetWidth()
{
document.MyForm.selectboxname.style.width = 105;
}
</script>

<form name=&quot;MyForm&quot;>
<SELECT style=&quot;width:105px&quot; onmousedown=&quot;changeWidth()&quot; onchange=&quot;resetWidth()&quot; name=&quot;selectboxname&quot; SIZE=&quot;1&quot;>
<OPTION value=&quot;none&quot; selected>-Select Here-</OPTION>
<OPTION VALUE=&quot;yourvalue1&quot;>Google</OPTION>
<OPTION VALUE=&quot;yourvalue2&quot;>Yahoo</OPTION>
<option value=&quot;yourvalue3&quot;>something goes here</option>
</SELECT><br><br>
<input type=&quot;submit&quot; value=&quot;go for it&quot; name=&quot;submit1&quot; >
</form>

You can leave the 'onchange' if you don't want to reset the width after a selection.

Hope this helps,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top