Hi, uhm can anyone help me out in creating a list box or a drop-down that has a standard size. Here's an example that I really want to display:

<select name='color[]' size=2 multiple>
<option value='' selected>Select Item</option>
<option value='blue'>Blue</option>
<option value='green'>Green</option>
<option value='red'>Red</option>
<option value='yellow'>Yellow</option>
<option value='white'>White</option>
</select>

Say, I just wanted to display a 3 letter only output. So if the option exceeds 3 letters, it should not display the succeeding letters. Its like the list box or drop-down should have a standard size in terms of letters not visible options since select tag do have a 'size' attribute that can manipulate the visible display of options.

Do you mean something like this:

<select name="color[]" size=2 multiple>
<option value="" selected>Select Item</option>
<?php
$colors=array('Blue','Green','Red','Yellow','White');
foreach ($colors AS $color) {
echo '<option value="'.strtolower($color).'">'.substr($color,0,3).'</option>'."\n";
}
?></select>

Well its sort of like this but still, I want to read the whole words in the list box. For example, I put 'Yellow Green', thus the size of the list box will widen so that the yellow green word will fit in the list box. I mean, the list box should have a fix size for the horizontal spacing. Like, when you add a longer word inside the list box, instead of fitting the word it should produce a horizontal scroll below the box.

I bit of css should do the trick.

<div style="border:1px #FFFFFF ridge; width:70px; height:70px; overflow-x: auto; overflow-y: auto;">
<select name='color[]' style="border:0px;" size=6 multiple>
<option value='' selected>Select Item</option>
<option value='blue'>Blue</option>
<option value='green'>Green</option>
<option value='red'>Red</option>
<option value='yellow'>Yellow</option>
<option value='white'>White</option>
</select>
</div>

Woah! It worked! Thank you very much! I was really on the verge of giving up when I remembered my account here at Dani Web. Its really such a good thing I've tried logging here.
Thanks again cwarn23. You've been a great help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.