We help IT Professionals succeed at work.

HTMLSelecctTag_Behaviour

sam15
sam15 asked
on
I have a web page that is built dynamically and displays addres info from a database.

One of the fields is "State".

I noticed a few times firefox 3.6 would not display the seleced state in the dropdown list correctly. This causes an issue as if user saves the form the state in the DB becaomes null.
for example, in list below it did not show "Arizona" as selected.

It does not seem to happen with IE. I also checked that table tags and every ROW and DATA tag has a matching one.

The issue does not happen all the time though. I cant tell what causes it.

I use this DOCTYPE declartion and i was wondering if it has to do with it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



This is the list i have

td>
           <SELECT NAME="p_state" TITLE="Select State.">
         <OPTION VALUE="">Select State</OPTION>
        <OPTION VALUE="AA">AA</OPTION>
        <OPTION VALUE="AB">ALBERTA</OPTION>
        <OPTION VALUE="AE">AE</OPTION>
        <OPTION VALUE="AK">Alaska</OPTION>
        <OPTION VALUE="AL">Alabama</OPTION>
       
        <OPTION VALUE="AP">AP</OPTION>
        <OPTION VALUE="AR">Arkansas</OPTION>
        <OPTION VALUE="AZ" selected>Arizona</OPTION>
        <OPTION VALUE="BC">BRITISH COLUMBIA</OPTION>
        <OPTION VALUE="CA">California</OPTION>
        <OPTION VALUE="CO">Colorado</OPTION>
        <OPTION VALUE="CT">Connecticut</OPTION>
        <OPTION VALUE="DC">District of Columbia</OPTION>
        <OPTION VALUE="DE">Delaware</OPTION>
       
        <OPTION VALUE="FL">Florida</OPTION>
        <OPTION VALUE="GA">Georgia</OPTION>
        <OPTION VALUE="GU">Guam</OPTION>
        <OPTION VALUE="HI">Hawaii</OPTION>
        <OPTION VALUE="IA">Iowa</OPTION>
        <OPTION VALUE="ID">Idaho</OPTION>
        <OPTION VALUE="IL">Illinois</OPTION>
        <OPTION VALUE="IN">Indiana</OPTION>
        <OPTION VALUE="KS">Kansas</OPTION>
       
        <OPTION VALUE="KY">Kentucky</OPTION>
        <OPTION VALUE="LA">Louisiana</OPTION>
        <OPTION VALUE="MA">Massachusetts</OPTION>
        <OPTION VALUE="MB">MANITOBA</OPTION>
        <OPTION VALUE="MD">Maryland</OPTION>
        <OPTION VALUE="ME">Maine</OPTION>
        <OPTION VALUE="MI">Michigan</OPTION>
        <OPTION VALUE="MN">Minnesota</OPTION>
        <OPTION VALUE="MO">Missouri</OPTION>
       
        <OPTION VALUE="MS">Mississippi</OPTION>
        <OPTION VALUE="MT">Montana</OPTION>
        <OPTION VALUE="NB">NEW BRUNSWICK</OPTION>
        <OPTION VALUE="NC">North Carolina</OPTION>
        <OPTION VALUE="ND">North Dakota</OPTION>
        <OPTION VALUE="NE">Nebraska</OPTION>
        <OPTION VALUE="NH">New Hampshire</OPTION>
        <OPTION VALUE="NJ">New Jersey</OPTION>
        <OPTION VALUE="NL">NEWFOUNDLAND AND LABRADOR</OPTION>
       
        <OPTION VALUE="NM">New Mexico</OPTION>
        <OPTION VALUE="NS">NOVA SCOTIA</OPTION>
        <OPTION VALUE="NT">NORTHWEST TERRITORIES</OPTION>
        <OPTION VALUE="NU">NUNAVUT</OPTION>
        <OPTION VALUE="NV">Nevada</OPTION>
        <OPTION VALUE="NY">New York</OPTION>
        <OPTION VALUE="OH">Ohio</OPTION>
        <OPTION VALUE="OK">Oklahoma</OPTION>
        <OPTION VALUE="ON">ONTARIO</OPTION>
       
        <OPTION VALUE="OR">Oregon</OPTION>
        <OPTION VALUE="PA">Pennsylvania</OPTION>
        <OPTION VALUE="PE">PRINCE EDWARD ISLAND</OPTION>
        <OPTION VALUE="PR">Puerto Rico</OPTION>
        <OPTION VALUE="QC">QUEBEC</OPTION>
        <OPTION VALUE="RI">Rhode Island</OPTION>
        <OPTION VALUE="SC">South Carolina</OPTION>
        <OPTION VALUE="SD">South Dakota</OPTION>
        <OPTION VALUE="SK">SASKATCHEWAN</OPTION>
       
        <OPTION VALUE="TN">Tennessee</OPTION>
        <OPTION VALUE="TX">Texas</OPTION>
        <OPTION VALUE="UT">Utah</OPTION>
        <OPTION VALUE="VA">Virginia</OPTION>
        <OPTION VALUE="VI">U.S. Virgin Islands</OPTION>
        <OPTION VALUE="VT">Vermont</OPTION>
        <OPTION VALUE="WA">Washington</OPTION>
        <OPTION VALUE="WI">Wisconsin</OPTION>
        <OPTION VALUE="WV">West Virginia</OPTION>
       
        <OPTION VALUE="WY">Wyoming</OPTION>
        <OPTION VALUE="YT">YUKON TERRITORY</OPTION>
        </SELECT>
            </td>

Comment
Watch Question

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
That DOCTYPE declaration is incomplete.  Should be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">

from http://www.w3.org/QA/2002/04/valid-dtd-list.html

Author

Commented:
is this mandatory? you think that may cause issues?

I had webpages where I started with <HTML> and they seemed tow work fine.
Do you think it will cause unpredictable issues with browsers.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Never heard of such a thing.

you are sure there are not other things going on?

Did you try firebug to see what is sent?
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
sam15, you have argued with every suggestion made on your questions so far.  You asked, I answered with a link to the standards for DOCTYPES.  I know that incomplete DOCTYPES cause the browser to act differently.  Sometimes only slightly.  But the purpose of DOCTYPES is to tell the browser what standards to use when interpreting a web page.

Author

Commented:
I did change the DOCTTYPE and problem persists.

I think i know what causes this strange behaviour which seemsto happen only with firefox 3.6.

I have 3 different state dropdown lists on the page. Each has a different name like: p_state, p_ag_state, p_ad_state.

WHen the database value was set to california, the 3rd dropdown was showing alabama selected even though the "VIEW SOURCE" shows california being selected.

WHen I commented the first two state dropdown lists, the 3rd one displayed correctly and set at california. The first one was set to alabama and browser seems to apply same selection to the 3rd one which is kind of strange.



Fixer of Problems
Most Valuable Expert 2014
Commented:
I didn't expect the DOCTYPE would fix the dropdown problem.  I have Firefox 3.6.17 running on one computer and it shows no problems for me with your dropdown list.  I'm wondering if that copy of Firefox has a problem.  Show us the whole page (please put it in the code section this time) so we have a chance of figuring out what is going on.  Since you said it worked in all the other browsers, it may be time to give up this problem that no one else can duplicate.

Author

Commented:
Yes, but as  I explained i do not think you tested with 3 state dropdown lists on same page. If you only have one dropdown list selection works fine. I will save a copy and post the page.

Author

Commented:
I could not replicate the issue again today. BUt now I am suspecting that IFerfox maybe getting a webpage from cache instead from database. but still the view source for selected state should match the web screen display.