Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3613
  • Last Modified:

selected="selected" not working on firefox

I have a select box in a webpage that depending on a database registry it puts the value select="selected" on the option tag in the html...

this is accomplished... but the problem is althoug in the html code the option shows that it is selected firefox ignores it... in IE7 works fine... i don't know what could be the problem here's the code that prints the selected attribute...

while ($dato = mysql_fetch_object($datos))
            {
                  if ($center->address->state == $dato->id)
                  {
                        print("<option selected='selected' value='$dato->id'> $dato->name </option>");
                  }
                  else
                  {
                        print("<option value='$dato->id' > $dato->name </option>");
                  }
            }

this works fine and in the web page the result is:

<select name="_state" id="_state">
    <option value="null">Choose a State</option>
    <option value='1'>Texas</option>
    <option selected='selected' value='2' selected>California</option>
    <option value='3'>Washington</option>  
</select>

in firefox the selected option is always the "Choose a State" one...

I have search for a solution for this but haven't found any... is this a firefox bug??

thanks in advance...

Memo.
0
bluememon
Asked:
bluememon
  • 2
1 Solution
 
David S.Commented:
It seems fine in Firefox 1.0.7, 1.5.x and 2.0.x (all on WinXP).
0
 
bluememonAuthor Commented:
Ohhh the problem was mine... I was trying to refresh the page and the drop down menu stayed where I selected even if the option california had the selected printed...

I'm going to be more careful next time I refresh my pages to test my code...

thanks for pointing me that out ^__________^

Memo.
0
 
David S.Commented:
You're welcome. Try pressing Ctrl + F5 to force a full reload in the future.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now