[Javascript] select box question

Shawn Milo ShawnMilo at runbox.com
Thu Jan 6 14:41:21 CST 2005


Please explain more clearly. What is it you want to have happen?

Shawn

> I tried your test and it works, but it only shows the added spaces when 
> you click on the select box. I need those blank spaces shown all the 
> time, even when the user isn't clicking on it.  Is there some way to get 
> that working?
> 
> Shawn Milo wrote:
> 
> >Tyson:
> >
> >Hi. You can use CSS to do this:
> >document.forms[0].my_select_box[document.forms[0].my_select_box.length - 1].style.wordSpacing = '5em';
> >
> >
> >Full working and tested HTML below.
> >
> >Shawn
> >
> >
> >
> >
> ><html>
> ><head>
> >
> ><title>Javascript Test</title>
> >
> ><script type="text/javascript">
> >
> >
> >   function testStuff(){
> >      //document.forms[0].my_select_box.options[document.forms[0].my_select_box.length] = new Option('hello        hi');
> >      //document.forms[0].my_select_box.options[document.forms[0].my_select_box.length] = new Option('hello &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hi');
> >      document.forms[0].my_select_box.options[document.forms[0].my_select_box.length] = new Option('hello hi');
> >
> >      document.forms[0].my_select_box[document.forms[0].my_select_box.length - 1].style.backgroundColor = '#fad762';
> >      document.forms[0].my_select_box[document.forms[0].my_select_box.length - 1].style.fontSize = '17pt';
> >      document.forms[0].my_select_box[document.forms[0].my_select_box.length - 1].style.wordSpacing = '5em';
> >   }
> >
> ></script>
> ></head>
> >
> ><body>
> >
> >   <form id="testForm" method="post" action="./test.html">
> >
> >      <select id="my_select_box">
> >         <option value="0">0</option>
> >         <option value="1">1</option>
> >
> >      </select>
> >
> >      <input type="button" id="btnTest" value="This is a test." onclick="testStuff();" />
> >   </form>
> >
> ></body>
> >
> >
> >
> >
> >  
> >
> >>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.length] 
> >>= 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
> >>
> >>    
> >>
> >_______________________________________________
> >Javascript mailing list
> >Javascript at LaTech.edu
> >https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> >  
> >
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 



More information about the Javascript mailing list