[Javascript] select box question

Mckinney, Lori K lori.mckinney at intergraph.com
Fri Jan 7 09:02:28 CST 2005


Can you create your option then change the text using the unescape and the
non-breaking unicode character?

document.forms[0].my_select_box.options[document.forms[0].my_select_box.leng
th-1].text = "hi" + unescape('%A0%A0%A0%A0%A0') + "hi" ;

where you use one %A0 for each space?

Or create it 

var hsp = String.fromCharCode(0xA0);
var hsp5 = hsp + hsp + hsp + hsp + hsp;
document.forms[0].my_select_box.options[document.forms[0].my_select_box.leng
th] = new Option ('hi' + hsp5 +  + 'hi')

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of tyson
Sent: Thursday, January 06, 2005 2:01 PM
To: javascript at LaTech.edu
Subject: [Javascript] select box question


Hi-
   When I add an item into my select box through javascript, I want 
multiple blank spaces to be kept in the string that's being added.  For 
some reason it only allows one blank space at a time. Here's my code-

##########
document.forms[0].my_select_box.options[document.forms[0].my_select_box.leng
th] 
= new Option ('hello     hi')
##########

There should be five spaces between the 'hello' and 'hi', but only one 
blank space shows up in the select box.  I've tryed adding the spaces 
with the char_code, that doesn't work.  I've also tryed adding spaces 
with &nbsp, and that doesn't work.  Any help would be appreciated.

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list