I am attempting to add options dynamically to a SELECT field. It works except that I need to indent the text. If I just add blank spaces at the front of the text, then IE 5.5 has no problems, but NS 7.0 trims the whitespace. If I use ' ' instead of spaces, then both IE and NS display as part of the text instead of interpreting it correctly. Now this is only with a dynamic generation of the option entry. If I hand-code this in HTML, the is correctly interpreted by both IE and NS and the indentation works perfectly. Have you ever run into this and if so, do you have a solution?
Here is some sample code, so you can see what I am talking about.
Hand-coding example (the first option will be indented and the 2nd option is not indented -- both IE 5.5+ and NS 7.0 act the same). So it obvious that the whitespace is being trimmed from this example, but the is respected.
<select name="AllScreens" id="AllScreens" size="10" ondblclick="expandOrContractMenu();">
<option> Should have 2 spaces in front of this text</option>
<option> Should have 4 spaces in front of this text</option>
Dynamically adding to the above select tag example follows. Assume that label and value vars below have already been calculated. It does not matter if indent uses spaces or . I can't get NS to respect the indentation. (Remember that following works with IE, but if I use then IE displays as a part of the text, unlike the hand-coded example above).
indent = ' ';
for (ii = 1; ii < splitArray.length; ii++) indent += ' ';
var menuOption = new Option (indent+label, value, false, false);