cooldude832 Posted January 7, 2008 Share Posted January 7, 2008 I have a list of states from php being generated and if it matches the users value it should say <option value="Michigan" selected="selected" >Michigan</option> (if it was Michigan for say) ie selects Michigan fine, but FF shows in the source code <option value="Michigan" selected="selected" >Michigan</option> but doesn't selected instead defaults to the first item of Alabama??? this is the whole outputted selected <html> State: <select name="state"> <option value="Alabama" >Alabama</option> <option value="Alaska" >Alaska</option> <option value="Arizona" >Arizona</option> <option value="Arkansas" >Arkansas</option> <option value="California" >California</option> <option value="Colorado" >Colorado</option> <option value="Connecticut" >Connecticut</option> <option value="Delaware" >Delaware</option> <option value="District of Columbia" >District of Columbia</option> <option value="Florida" >Florida</option> <option value="Georgia" >Georgia</option> <option value="Hawaii" >Hawaii</option> <option value="Idaho" >Idaho</option> <option value="Illinois" >Illinois</option> <option value="Indiana" >Indiana</option> <option value="Iowa" >Iowa</option> <option value="Kansas" >Kansas</option> <option value="Kentucky" >Kentucky</option> <option value="Louisiana" >Louisiana</option> <option value="Maine" >Maine</option> <option value="Maryland" >Maryland</option> <option value="Massachusetts" >Massachusetts</option> <option value="Michigan" selected="selected" >Michigan</option> <option value="Minnesota" >Minnesota</option> <option value="Mississippi" >Mississippi</option> <option value="Missouri" >Missouri</option> <option value="Montana" >Montana</option> <option value="Nebraska" >Nebraska</option> <option value="Nevada" >Nevada</option> <option value="New Hampshire" >New Hampshire</option> <option value="New Jersey" >New Jersey</option> <option value="New Mexico" >New Mexico</option> <option value="New York" >New York</option> <option value="North Carolina" >North Carolina</option> <option value="North Dakota" >North Dakota</option> <option value="Ohio" >Ohio</option> <option value="Oklahoma" >Oklahoma</option> <option value="Oregon" >Oregon</option> <option value="Pennsylvania" >Pennsylvania</option> <option value="Rhode Island" >Rhode Island</option> <option value="South Carolina" >South Carolina</option> <option value="South Dakota" >South Dakota</option> <option value="Tennessee" >Tennessee</option> <option value="Texas" >Texas</option> <option value="Utah" >Utah</option> <option value="Vermont" >Vermont</option> <option value="Virginia" >Virginia</option> <option value="Washington" >Washington</option> <option value="West Virginia" >West Virginia</option> <option value="Wisconsin" >Wisconsin</option> </select><br /> </html> as you can see Michigan is selected but FF decides to highlight Alabama instead Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/ Share on other sites More sharing options...
goldberg Posted January 7, 2008 Share Posted January 7, 2008 I think it must be an error outside the selected tags because I have a very similar code that functions fine. State: <select name="state"> <option value="bama">AL</option> <option>AK</option> <option>AS</option> <option>AZ</option> <option>AR</option> <option>CA</option> <option>CO</option> <option>CT</option> <option>DE</option> <option>DC</option> <option>FM</option> <option>FL</option> <option>GA</option> <option>GU</option> <option>HI</option> <option>ID</option> <option>IL</option> <option>IN</option> <option>IA</option> <option>KS</option> <option>KY</option> <option>LA</option> <option>ME</option> <option>MH</option> <option value="maryland" selected="selected">MD</option> <option>MA</option> <option>MI</option> <option>MN</option> <option>MS</option> <option>MO</option> <option>MT</option> <option>NE</option> <option>NV</option> <option>NH</option> <option>NJ</option> <option>NM</option> <option>NY</option> <option>NC</option> <option>ND</option> <option>MP</option> <option>OH</option> <option>OK</option> <option>OR</option> <option>PW</option> <option>PA</option> <option>PR</option> <option>RI</option> <option>SC</option> <option>SD</option> <option>TN</option> <option>TX</option> <option>UT</option> <option>VT</option> <option>VI</option> <option>VA</option> <option>WA</option> <option>WV</option> <option>WI</option> <option>WY</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/#findComment-432975 Share on other sites More sharing options...
cooldude832 Posted January 7, 2008 Author Share Posted January 7, 2008 nope ran the output on w3 no issues Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/#findComment-433020 Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 I use it this way <option value="Michigan" selected > seems to work fine Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/#findComment-433030 Share on other sites More sharing options...
cooldude832 Posted January 7, 2008 Author Share Posted January 7, 2008 yeah but w3 says <option value="Michigan" selected >Michigan</option> "VI delimiter" is a technical term for the equal sign. This error message means that the name of an attribute and the equal sign cannot be omitted when specifying an attribute. A common cause for this error message is the use of "Attribute Minimization" in document types where it is not allowed, in XHTML for instance. How to fix: For attributes such as compact, checked or selected, do not write e.g <option selected ... but rather <option selected="selected" ... shouldn't be that the right way fails Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/#findComment-433079 Share on other sites More sharing options...
phpQuestioner Posted January 7, 2008 Share Posted January 7, 2008 do this instead: <option value="Michigan" selected="true">Michigan</option> Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/#findComment-433118 Share on other sites More sharing options...
PFMaBiSmAd Posted January 8, 2008 Share Posted January 8, 2008 I just ran the code in post #1 of this thread in FF 2.0.0.11 (latest) and it selects Michigan. And if you select something else and refresh, it goes back to Michigan. I suspect you have something else going on in your form or in your browser. Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/#findComment-433144 Share on other sites More sharing options...
cooldude832 Posted January 8, 2008 Author Share Posted January 8, 2008 I've used this a million times <?php echo "State: <select name=\"state\">\n"; foreach($states as $value){ echo "<option value=\"".$value."\" "; if($_SESSION['Fields']['state'] == $value){ echo "selected "; } echo " >".$value."</option>\n"; } echo "</select><br />\n"; ?> but the w3 says the whole output is valid Quote Link to comment https://forums.phpfreaks.com/topic/84903-selectedselected-not-working-in-ff-but-in-ie/#findComment-433183 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.