Page 1 of 1

I finally found something I don't like about firefox

Posted: Sat Jul 30, 2005 10:08 pm
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.

Posted: Sat Jul 30, 2005 10:11 pm
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.

Posted: Sat Jul 30, 2005 10:16 pm
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 :-)

Posted: Sun Jul 31, 2005 1:33 am
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. :)

Posted: Sun Jul 31, 2005 5:44 am
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:

Posted: Sun Jul 31, 2005 7:58 am
by m3mn0n

Posted: Sun Jul 31, 2005 10:41 am
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.

Posted: Sun Jul 31, 2005 11:50 am
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. :)

Posted: Sun Jul 31, 2005 11:53 am
by Ambush Commander
Yes, yes, that's exactly what I meant.