[Javascript] select box question

Roger Roelofs rer at datacompusa.com
Thu Jan 6 17:49:07 CST 2005

Paul & Tyson,

On Jan 6, 2005, at 6:21 PM, Paul Novitski wrote:

> Shawn,
> I can see your wordspacing idea work only as long as the data values 
> are all single words of the same length.  Otherwise, the second column 
> will have a ragged left edge mimicking the ragged right edge of the 
> first column, and a third column if any will be further distorted.  
> The only way I can see to get that second column (at position C2) to 
> line up is to pad each first-column word (of length C1) with N blank 
> spaces where N = C2 - C1.  Tyson said that   didn't work when 
> applied with Javascript because it seemed to be interpreted as a 
> string, not the html character code... I'd like to see that, and if 
> debuggable it might be the best solution.
Unfortunately, even that won't work unless the specified font is 
monospace.  Not all browsers let you style selects well because they 
use native OS widgets.  The following code works in safari & gecko, but 
I can't test ie/win.

function testStuff(){
	// this works in safari and ff1.0
	theEl = document.forms[0].my_select_box;
	theEl.options[theEl.length] = new Option('hello        hi');
	theEl.options[theEl.length - 1].style.whiteSpace = 'pre';

> I can see building a multiple-column select list using a table inside 
> a scrolling div, the height of which toggles between one row and 
> several rows.  Not standards-compliant by a long shot, but doable.
I thought about this too, but it wouldn't behave like a select without 
major work.

Thanks, Shaun, it has been an interesting day...


Roger Roelofs
Datacomp Appraisal Services

More information about the Javascript mailing list