SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    whitespace using new Option()

    Try this code:

    Code:
    <form name="test">
    <select name="testing">
    <option value="1">& nbsp;& nbsp;sdfsfsdf</option>
    </select>
    </form>
    
    <script language="javascript">
    var option = new Option("& nbsp;& nbsp;Wednesday", 2);
    document.test.testing.options.add(option, 2);
    </script>
    Why does the white space work using &nbsp; for the select option that is written out, but the one generated by the script is just displayed. Any ideas about what can be done about this? I really need the whitespace for formatting of a menu type system of categories which needs indentation.

    edit, have added a space between & and nbsp; because otherwise it was turning into whitespace here

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you put the spaces in there using your space bar that works. Like this:

    var option = new Option(" Wednesday", 2);

    **Note: there should be spaces there at the beginnin, but the forum is removing them.
    Last edited by requestcode; Sep 6, 2002 at 05:31.

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Spaces of that format do not, unfortunatly, work on NS6


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •