default "selected" option in firefox not working

Reply

Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

default "selected" option in firefox not working

 
0
  #1
Jan 8th, 2007
Hey, I'm trying to use a simple select menu, and I would like to set one of the values to be the default, and it works great in IE, but not in firefox. Here is a sample:

HTML and CSS Syntax (Toggle Plain Text)
  1. <select name="test">
  2. <option value="Test 1">Test 1</option>
  3. <option value="Test 2">Test 2</option>
  4. <option value="Test 3" selected>Test 3</option>
  5. </select>

Notice that I am trying to get "Test 3" to show up as the default option. It works fine in IE, but how do I get it to work in Firefox too?
Last edited by nathanpacker; Jan 8th, 2007 at 7:33 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: default "selected" option in firefox not working

 
0
  #2
Jan 8th, 2007
are you using an HTML or XHTML doctype?

in HTML doctypes it's ok to set boolean attributes without values, in XHTML doctypes it is not.

in XHTML you have got to use:

selected="selected", or selected="yes", or selected="true"
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: default "selected" option in firefox not working

 
0
  #3
Jan 9th, 2007
Originally Posted by MattEvans View Post
are you using an HTML or XHTML doctype?

in HTML doctypes it's ok to set boolean attributes without values, in XHTML doctypes it is not.

in XHTML you have got to use:

selected="selected", or selected="yes", or selected="true"
Lol, well, I don't know enough to stay XHTML valid, but if I know it I will, so thanks for the info.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: default "selected" option in firefox not working

 
0
  #4
Jan 9th, 2007
does it work in Firefox if you use one of those atttribute values instead of just 'selected'?

it's not so much a question of staying valid, as being compatible.

an absolutely 'correct' XML parser should reject that line of code and output a warning/error message instead of an expected output. But, Firefox only ever truely parses a page as X(HT)ML if you serve the Content-Type:application/xhtml+xml* header.

* not sure if that's the correct type, it's not an easy one to remember.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: default "selected" option in firefox not working

 
0
  #5
Jan 9th, 2007
Originally Posted by MattEvans View Post
does it work in Firefox if you use one of those atttribute values instead of just 'selected'?

it's not so much a question of staying valid, as being compatible.

an absolutely 'correct' XML parser should reject that line of code and output a warning/error message instead of an expected output. But, Firefox only ever truely parses a page as X(HT)ML if you serve the Content-Type:application/xhtml+xml* header.

* not sure if that's the correct type, it's not an easy one to remember.
Well, to be honest, after I read your reply, I went back to go change it, and I decided to look at the page one more time, and it was working! I have no idea why. So I didn't change it. Maybe I'll change it just to please our curiosity now...
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: default "selected" option in firefox not working

 
0
  #6
Jan 9th, 2007
Ok, I just tried it again. And I realized when I said it was working before, it was because I was simply refreshing the page, but apparently Firefox retains all the information, so it didn't matter what had "selected" in the script, it was just selecting the one that was previously selected.

So I closed the window, opened a new one, and realized it wasn't working with just "selected" in the script. When i changed it to selected="yes", it worked.
Thanks.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 38
Reputation: kevindougans is an unknown quantity at this point 
Solved Threads: 1
kevindougans kevindougans is offline Offline
Light Poster

Re: default "selected" option in firefox not working

 
0
  #7
Oct 18th, 2007
Thanks a lot, would have spent hours trying to get it working if it wasn't for this thread.

The outcome: Firefox retains the last value you had a form field at when hitting refresh so to debug/test add "?1" or something similar to the URL to restart from afresh. Ctrl+Refresh doens't even work.

Next of all, 'SELECTED="yes"' worked in the end for me.

Thanks again!
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 176
Reputation: trudge is an unknown quantity at this point 
Solved Threads: 20
trudge trudge is offline Offline
Junior Poster

Re: default "selected" option in firefox not working

 
0
  #8
Oct 19th, 2007
From what I know, Shift-Refresh will force most Mozilla browsers to grab a new copy of a page from the server rather than cache.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 38
Reputation: kevindougans is an unknown quantity at this point 
Solved Threads: 1
kevindougans kevindougans is offline Offline
Light Poster

Re: default "selected" option in firefox not working

 
0
  #9
Oct 19th, 2007
yes you are correct, i edited content on the page and the content change but for whatever reason it doesn't refresh the form fields from the options you had last selected. i guess some would find this feature cool so they don't have to keep refilling forms out.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: default "selected" option in firefox not working

 
0
  #10
Oct 21st, 2007
Whether or not to clear fields is a setting.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC