943,985 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Jan 8th, 2007
0

default "selected" option in firefox not working

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
Jan 8th, 2007
0

Re: default "selected" option in firefox not working

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"
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jan 9th, 2007
0

Re: default "selected" option in firefox not working

Click to Expand / Collapse  Quote originally posted by MattEvans ...
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.
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
Jan 9th, 2007
0

Re: default "selected" option in firefox not working

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.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jan 9th, 2007
0

Re: default "selected" option in firefox not working

Click to Expand / Collapse  Quote originally posted by MattEvans ...
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...
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
Jan 9th, 2007
0

Re: default "selected" option in firefox not working

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.
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
Oct 18th, 2007
0

Re: default "selected" option in firefox not working

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!
Reputation Points: 13
Solved Threads: 7
Junior Poster
kevindougans is offline Offline
110 posts
since Oct 2007
Oct 19th, 2007
0

Re: default "selected" option in firefox not working

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.
Reputation Points: 18
Solved Threads: 20
Junior Poster
trudge is offline Offline
176 posts
since Sep 2007
Oct 19th, 2007
0

Re: default "selected" option in firefox not working

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.
Reputation Points: 13
Solved Threads: 7
Junior Poster
kevindougans is offline Offline
110 posts
since Oct 2007
Oct 21st, 2007
0

Re: default "selected" option in firefox not working

Whether or not to clear fields is a setting.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: login with cookies
Next Thread in HTML and CSS Forum Timeline: Google says hello and waves goodbye





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC