
February 23rd, 2013, 10:02 PM
|
 |
Contributing User
|
|
|
|
You have to replace the white-space with the escape version of a non-breaking space. Then you have to unescape it, before displaying it in your option tag(s). And that... my friend, will look a little something like this:
Code:
<select id="sel">
<option value=""></option>
</select>
<script>
var text ="abc xyz";
text = text.replace(/ /g,"%A0");
var value ="val";
var contrlObj = document.getElementById("sel");
var newOpt = new Option(unescape(text),value);
contrlObj.options[0] = newOpt;
</script>
Last edited by web_loone08 : February 23rd, 2013 at 10:29 PM.
|