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!

Setting WIDTH for LIST CONTROL

Status
Not open for further replies.

MENON

Programmer
Jul 23, 2001
28
US
Hi All,

I have the following code in my HTML
<SELECT name=list MULTIPLE size=10>
<OPTION> </OPTION>
</SELECT>

But it appears as THIN strip, Is there a way I can set the width even though there are no items in it. The items are populated dynamically by script.

Thanks,
R. Menon
 
-> size is the length of the select box ie in your case you'll have 10 elements displayed, whatever the actual number of elements)
-> to fix a minimum width, there is no attribute ... it is the longest elements that determines the width. Meaning, you have to use a <option>-----------------------</option> or <option>&nbsp; &nbsp; &nbsp; </option> to pre set it - no other way !!
 
Hi iza,

Thanks for your response. I had tried
<option> </option>
and that doesn't work either.

<option>-----------------------</option> does work but it doesn't look alright. Any other ideas?

Thanks,
 
hie
may be non-breakin spaces?
i mean
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
just an idea, didnt checked it.. regards, vic
 
menon, sorry, i actually wrote &quot;& n b s p ;&quot; but it was translated as &quot; &quot;
vituz, you've been trapped as well !!! didnt check either - but it has to work !!
 
the alternative is to use...

<select style=&quot;width:100px;&quot;>
<option>my option</option>
<option>my other option</option>
</select>
 
oh yes ! i thought menon wanted an html solution - not a css one
but yes, in that case, css is best please check FAQ183-874 :)
 
Hi All,

Thanks all for your response.
SecretSquirell, I had tried stylesheets alternative, but it doesn't work in Netscape. Hence I was looking for a generic solution. iza and vituz, I had guessed maybe you typed &quot;& n b s p ;&quot;. However the issue with that is the width of LIST is never constant unless you leave a blank line always at TOP.
At this point there seems to be no perfect alternative so we have decided to stick to
<option>-----------Search Results------------</option> even though we are not too happy with this.
Any ideas???

Thanks,
R. Menon
 
use this:
<select name=&quot;list&quot; WIDTH=&quot;200&quot; STYLE=&quot;width:200px&quot;>

both Netscape(WIDTH=&quot;200&quot;) and IE(STYLE=&quot;width:200px&quot;) understand
 
Thanks danghien! That works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top