How to create new option with more space between text

F

fusillator

I would like to create new option with more than one space as text in a
select element, is it possible?

I tried this statements:

var selT=document.getElementById('SelectObj');
selT.add(new Option("Space between text","xyz"),selT.options[0]);

and also:

var selT=document.getElementById('SelectObj');
selT.add(new Option("Space between    text",
"xyz"),selT.options[0]);

without get any space between words.
 
M

Martin Honnen

fusillator said:
var selT=document.getElementById('SelectObj');
selT.add(new Option("Space between    text",
"xyz"),selT.options[0]);

nbsp has the Unicode 160 so you can do e.g.
new Option("Space between" + String.fromCharCode(160, 160, 160, 160)
+ "text", "xyz")
or
new Option("Space between\u00A0\u00A0\u00A0\u00A0text", "xyz")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top