<OPTION SELECTED not working on reload

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
banditski
Guest

<OPTION SELECTED not working on reload

Post by banditski »

hi there,

i don't know if this is an intended "feature" of firefox, but it appears that a <SELECT> box will not default to the <OPTION SELECTED> value when a page is reloaded. to be more specific, the correct option will be selected on initial load, and the first refresh, but not subsequent refreshes.

it works fine in ie and opera. i doubt it makes any difference, but the code is being generated by php, so i suppose it's possible that that *might* have something to do with it.

is this a bug in firefox?? if so, can anyone think of a workaround?? (please bear in mind that i'm going to be adding an onChange() to refresh the page when the user changes the country.)

Code: Select all

<HTML>
<HEAD><TITLE>player</TITLE></HEAD>
<BODY>
<FORM NAME="myForm" METHOD="post" ACTION="player.php">
user name <INPUT TYPE="text" NAME="user_name" VALUE="banditski"><BR>
real name <INPUT TYPE="text" NAME="real_name" VALUE="banditski"><BR>
email address <INPUT TYPE="text" NAME="email" VALUE="banditski"><BR>
<BR>
location:<BR>
country <SELECT NAME="country" ID="country"><BR>
<OPTION VALUE="CA">Canada</OPTION>
<OPTION VALUE="US">United States</OPTION>
<OPTION VALUE="DE">Germany</OPTION>
<OPTION VALUE="NL" SELECTED>Holland</OPTION>
<OPTION VALUE="FR">France</OPTION>
<OPTION VALUE="MX">Mexico</OPTION>
</SELECT><BR>
<BR>
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>
Guest
Guest

Post by Guest »

bump
TerryGinSanDiego
Guest

Post by TerryGinSanDiego »

I noticed the exact same behavior Banditski...since no-one has replied to you, I "bumped" it into another topic
cexshun
Posts: 9
Joined: March 15th, 2004, 12:18 pm

Post by cexshun »

This bug is of dire importance. Can someone look into this?

I have a PHP quoting system. If one user changes the status of a quote from "Open" to "Accepted", the code changes the selected="selected" to the proper item. However, If I refresh after another user makes that change, the old item is still selected. However, upon examining the code, the new item SHOULD be selected.

This is causing major issues in the office. Why is Firefox ignoring valid XHTML code?
old np
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old np »

I'll move this to Web Development, where the unregistered will have to register to post.
dakboy
Posts: 3451
Joined: November 30th, 2002, 12:30 pm

Post by dakboy »

I'd love to see valid code that actually exhibits this behaviour. banditski's code is neither valid nor has any option that's marked as selected, and cexshun provides no code. I can't say I've seen this happen myself, but that's based on what little we know here.
dakboy
Posts: 3451
Joined: November 30th, 2002, 12:30 pm

Post by dakboy »

cexshun wrote:This bug is of dire importance. Can someone look into this?

I have a PHP quoting system. If one user changes the status of a quote from "Open" to "Accepted", the code changes the selected="selected" to the proper item. However, If I refresh after another user makes that change, the old item is still selected. However, upon examining the code, the new item SHOULD be selected.

This is causing major issues in the office. Why is Firefox ignoring valid XHTML code?
Are you sure that Firefox just isn't pulling the old version from cache?
User avatar
jqp
Posts: 5070
Joined: November 17th, 2004, 10:56 am
Location: In a box
Contact:

Post by jqp »

I don't think I'd say "dire importance..."

It's a firefox "feature" to keep the selected items and entered text in place when you reload or something...

If you want to reset the form, add this to the javascript:
window.onload = function() { document.getElementById("formid").reset(); }
cexshun
Posts: 9
Joined: March 15th, 2004, 12:18 pm

Post by cexshun »

Here's the valid code:

<select name="close">
<option value="1" selected="selected">Open</option>
<option value="2">Accepted</option>
<option value="6">Lost</option>
<option value="7">Archived</option>
</select>

Renders fine. Now edit the code to say:
<select name="close">
<option value="1">Open</option>
<option value="2" selected="selected">Accepted</option>
<option value="6">Lost</option>
<option value="7">Archived</option>
</select>

Save and refresh in the browser. The code clearly states something completely different then what is rendered. This 'feature' makes writing dynamic web applications completely useless when migrating users to FF.

So, if my user makes a change to the company name and clicks submit, the value of said option box will be sent as 1 instead of 2 as it should be. This is causing a large amount of trouble.

FF is not pulling from cache. The first thing I tried to fix this was cache controls and page expiration. If I view source, the correct source is displayed, but not rendered.
dakboy
Posts: 3451
Joined: November 30th, 2002, 12:30 pm

Post by dakboy »

[edit]Didn't see the last line in that reply.
cexshun
Posts: 9
Joined: March 15th, 2004, 12:18 pm

Post by cexshun »

On the second instance, I am seeing the proper source with selected="selected" on the correct item. Yet the old item is the one selected in the rendered page.
User avatar
jqp
Posts: 5070
Joined: November 17th, 2004, 10:56 am
Location: In a box
Contact:

Post by jqp »

Here's what's happening.

http://websandbox.net/temp/temp.html
The information that the user inputs stays there even if they reload the page... it doesn't reset to the default information just because the page reloads. The same usually goes for the back button.

Imagine a long form with a lot of text boxes, radio buttons, and select boxes. The user gets halfway through the long form and accidentally reloads the page one way or another. The user shouldn't have to re-enter all the same information just because the page reloads.

To say that this makes "dynamic web application ... useless" is stupid. Does your form really rely on the default option to be selected even if the page reloads? Sounds like some silly programming to me.

We could care less whether people migrate to Fx. We care more than web pages don't rely on any particular browser, no matter what browser that is, to function properly. We just want pages that are coded to standards so that they work properly in all modern browsers and degrade gracefully for older browsers and less fancy browsers.

edit: I know I wrote this earlier, but here's JavaScript good enough to get around the issue:

Code: Select all

window.onload = function() { document.getElementById("formid").reset(); }

But then again, should you really use a script to undo something that is more helpful to users than harmful?
Last edited by jqp on June 21st, 2005, 12:14 pm, edited 2 times in total.
Unarmed
Posts: 4941
Joined: July 31st, 2003, 1:26 pm

Post by Unarmed »

<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=46845" title="Bug 46845 - Form elements don't reset upon manually reloading page">Bug 46845 - Form elements don't reset upon manually reloading page (VERIFIED INVALID)</a>
User avatar
jqp
Posts: 5070
Joined: November 17th, 2004, 10:56 am
Location: In a box
Contact:

Post by jqp »

As per notes on that bug, Ctrl+F5 does reset the form fields.
Edit: IE6 Win does exactly the same thing - keep data on reload, reset form on Ctrl+F5
cexshun
Posts: 9
Joined: March 15th, 2004, 12:18 pm

Post by cexshun »

No need to get testy. Thanks for the explaination.

Although I'd tend to say that pages with "a lot of text boxes, radio buttons, and select boxes" would be "some silly programming" for the same reasons that you mention this as a feature.

Although I disagree that my code may be silly programming, I understand this is not the forum for such discussion.

Thanks for your time.
Post Reply