SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast Dolbex's Avatar
    Join Date
    Jun 2003
    Location
    Confused USA
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Select - "Selected" not working in Firefox

    Sorry if this should be in HTML, but I think it may be a PHP problem. For some reason when I generate dynamic option listings "<option value="x" selected>" does not work. By "not work" I mean that the combo box does not select that option by default on the form. It does work in IE6 but not FF.

    Any clues?

    Here is the output from my code

    Code:
    	<select name='name'><option value='1'>xxx</option>
    <option value='2'>bbb</option>
    <option value='3' selected>ccc</option>
    <option value='4'>ddd</option>
    
    <option value='5'>eee</option>
    <option value='6'>fff</option>
    <option value='7'>ggg</option>
    <option value='8'>hhh</option>
    <option value='9'>iii</option>
    <option value='10'>jjj</option>
    	</select>

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The above code does work in Firefox. 'ccc' is selected by default.

    If you made your own selection, refreshing/going back will keep the selection you made (just like what you typed into text inputs is still typed when you go back).

    Clear your cache, close your browser, go back to your test page and you should see that 'ccc' is selected.

  3. #3
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Try
    HTML Code:
    <option value="x" selected="selected">nnn</option>
    Saul

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Firefox is perfectly capable of interpreting HTML 4, where "selected" alone indicates the selected option.

  5. #5
    Always learning viveknarula's Avatar
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    I would like to suggest u to TRY what "php_daemon" is suggesting as i faced same problem i solve it by putting selected='selected'.

  6. #6
    SitePoint Enthusiast Dolbex's Avatar
    Join Date
    Jun 2003
    Location
    Confused USA
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman
    The above code does work in Firefox. 'ccc' is selected by default.

    If you made your own selection, refreshing/going back will keep the selection you made (just like what you typed into text inputs is still typed when you go back).

    Clear your cache, close your browser, go back to your test page and you should see that 'ccc' is selected.
    Right on. *slaps forehead*


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
  •