I finally found something I don't like about firefox

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

I finally found something I don't like about firefox

Post by josh »

I wanted to title this thread 'I finally found a bug in firefox' but I'm not sure if this is the intended functionality, you see I was writing a 'date selector' class (it's going to allow you to prompt users for a date and time using drop down boxes) and I started getting bugs when I coded the ability to let the date selector default to a certain time.

The way I was doing it was looping through an array of items to go in the drop down list, and on each iteration I was checking if the current item is == what we need to default it to, if so I would output the word "selected" so my html output looked like this:

Code: Select all

<option value=&quote;10&quote; selected>10</option>
Now, after seeing that the html was outputting the way intended but it wasn't defaulting to 10 (it defaulted to 1) I got really <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> needless to say. My first guess was xhtml compatibility so I changed it to

Code: Select all

<option value=&quote;10&quote; selected=&quote;selected&quote;></option>
Didn't work... grrrrrrr

What really stumped me is I was able to copy and paste my entire html output into dreamweaver and the wysiwyg engine correctly defaulted to 10, I then thought.. wait a minute, dreamweaver uses IE's dlls for parsing html right? So I load up my page in IE and everything works flawlessly.

Turns out the problem is if your drop down box is not inbetween <form> tags it won't default to what you tell it to. This is really stupid if it is an intended feature because a lot of web sites use drop downs with javascript for non form related tasks.

Just thought I'd post it on here in case anyone has a similiar problem, or if anyone knows what the purpose of this functionality is.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

According to the spec, all input/select/textarea's must be between form (and nested fieldset's these days as well). So FF is just obeying the spec.

I beleive the main reason for that requirement is accessibility. Page readers, lynx, and other really need/want to know exactly when user input is allowed or not.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Yeah, I guess that makes sense, I just wish I had known that before I spent 15 minutes reading over ALL of my code looking for errors, before I checked the html output and then tested it in IE. Oh well at least it taught me to always assume my script is working fine untill I can assess that the html output (or other means) suggests otherwise :-)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

jshpro2 wrote:Yeah, I guess that makes sense, I just wish I had known that before I spent 15 minutes reading over ALL of my code looking for errors, before I checked the html output and then tested it in IE. Oh well at least it taught me to always assume my script is working fine untill I can assess that the html output (or other means) suggests otherwise :-)
My golden rule is validate first.

With Firefox and the web dev toolbar, you dont have to wait til after anything. :)
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

never encountered this before...
you wrote:

Code: Select all

<option value=&quote;10&quote; selected=&quote;selected&quote;></option>
isnt it supposed to be...

Code: Select all

<option value=&quote;10&quote; selected></option>
thats always the way ive done it, it doesnt make sense what your doing, selected = selected :roll:
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

If you're in HTML 4.1, that's the right syntax. I got a nasty wakeup call about this technicality when I was validating one of my documents.

By the way, if you need your dropdown boxes to be inline (form is box), you can always use display:inline on your FORM to get around this problem.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

malcolmboston wrote:never encountered this before...
It seems odd, but its correct in both xhtml and html-4.01.

Basically, you have an attribute ("selected"), and it has a value. Until xhtml, the parsers generally assume that selected (the attribute) is set to selected, if you mention the attribute.

Even if you don't use xhtml, its good to get in the habit in html, and its valid code in html.
Ambush Commander wrote:If you're in HTML 4.1
There ain't no such beast. You probably meant html-4.01. :)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Yes, yes, that's exactly what I meant.
Post Reply