Closed Bug 257715 Opened 20 years ago Closed 19 years ago

selected component of <option> tag

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: rlaurie, Assigned: bugzilla)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3

I've noticed that when dumping an group of <option value='blah'> tags to output
using PHP that if I set one to <option value='blah' selected>, it won't actually
select it but rather defaults to first option available. IE functions as
expected (correctly) using the same script.

Reproducible: Always
Steps to Reproduce:
1.parse from a text file a list of <option> statements
2.str_replace a given option to make it selected
3.beat computer with head after spending 45 mins debugging script only to open
IE and see it work




My head hurt.
The 'bug' is due to lack of compatability with older html specs, specifically
attribute minimization. XML dictates selected="selected".
I also have this kind of problem:
Here is the html output, but firefox 1.0 won't display the selected option, but
the first option element. 
Why ?
How can I solve this?

Here's the output:

<select name="cat_select" id="cat_select">

          
        
					
        	 		   <option value="1" >Demo - CD</option>
			        
					
        	 		   <option value="2" >Demo - MC</option>
			        
					
        	 		   <option value="3" >Demo - Vinyl</option>
			        
					
        	 		   <option value="4" >Demo - Video</option>
			        
					
        	          <option value="5" selected="selected" >Album - CD</option>  
		        
					
        	 		   <option value="6" >Album - MC</option>

			        
					
        	 		   <option value="7" >Album - Vinyl</option>
			        
					
        	 		   <option value="8" >Album - DVD</option>
			        
					
        	 		   <option value="9" >Single</option>
			        
					
        	 		   <option value="10" >Sampler</option>
			        
		      
      
      </select>
Now I found a way to workaround this problem, but I don't know why this strange
behaviour appears:

Here are two HTML Tables. In the first table, the select box ist in the first
line of the table. In this case firefox 1.0 shows me the wrong element as
"selected".

When I move the select box some lines below , all select boxes will show the
correct values. Do you have any ideas ?

I should mention, that I produce the HTML output with PHP and the help of the
Smarty Template engine. That's why the template tags are inside.

Heres the first table:
Strange thing is, that the first select box doesn't work correctly, but the
second select box does.

<form name="form_release_new" method="post" action="">
  <table width="584" border="0">
    <tr align="left" valign="top">
      <td width="249"><strong>Medium*</strong></td>
      <td width="325"><select name="cat_select" id="cat_select">
        {section name=i loop=$releasecatdata}
			{if $releasecatdata[i].releasescatid == $releasedata.release_cat}
       			 <option value="{$releasecatdata[i].releasescatid}"
selected="selected">{$releasecatdata[i].releasescatname}</option>
        	{else}
      			<option value="{$releasecatdata[i].releasescatid}"
>{$releasecatdata[i].releasescatname}</option>
        	{/if}
        {/section}
      
      </select></td>
    </tr>
    <tr align="left" valign="top">
      <td><strong>Titel des Releases * </strong></td>
      <td><input name="releasename" type="text" id="releasename"
value="{$releasedata.releasename}" class="textarea"></td>
    </tr>
    <tr align="left" valign="top">
      <td><strong>Erscheinungsjahr*</strong></td>
      <td><input name="releaseyear" type="text" id="releaseyear"
value="{$releasedata.releaseyear}" size="4" maxlength="4"></td>
    </tr>
    <tr align="left" valign="top">
      <td><strong>K&uuml;nstler*</strong></td>
      <td><select name="artist_select" id="artist_select">
          
		{section name=i loop=$artistdata}
			{if $artistdata[i].bandid == $releasedata.release_artist_id}
          <option selected="selected"
value="{$artistdata[i].bandid}">{$artistdata[i].bandname}</option>
          	{else}
		<option  value="{$artistdata[i].bandid}">{$artistdata[i].bandname}</option>
			{/if}
		{/section}
      
      </select></td>
    </tr>
    <tr align="left" valign="top">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
</table>
</form>


And here is the second table, where everything is correct:
In this table both select boxes work correctly. Strange...

<form name="form_release_new" method="post" action="">
  <table width="584" border="0">
    <tr align="left" valign="top">
      <td width="249"><strong>Titel des Releases * </strong></td>
      <td width="325"><input name="releasename" type="text" id="releasename"
value="{$releasedata.releasename}" class="textarea"></td>
    </tr>
    <tr align="left" valign="top">
      <td><strong>Erscheinungsjahr*</strong></td>
      <td><input name="releaseyear" type="text" id="releaseyear"
value="{$releasedata.releaseyear}" size="4" maxlength="4"></td>
    </tr>
    <tr align="left" valign="top">
      <td><strong>K&uuml;nstler*</strong></td>
      <td><select name="artist_select" id="artist_select">
          
		{section name=i loop=$artistdata}
			{if $artistdata[i].bandid == $releasedata.release_artist_id}
          <option selected="selected"
value="{$artistdata[i].bandid}">{$artistdata[i].bandname}</option>
          	{else}
		<option  value="{$artistdata[i].bandid}">{$artistdata[i].bandname}</option>
			{/if}
		{/section}
      
      </select></td>
    </tr>
    <tr align="left" valign="top">
      <td><strong>Medium*</strong></td>
      <td><select name="cat_select" id="cat_select">
          
        {section name=i loop=$releasecatdata}
			{if $releasecatdata[i].releasescatid == $releasedata.release_cat}
       			 
          <option value="{$releasecatdata[i].releasescatid}"
selected="selected">{$releasecatdata[i].releasescatname}</option>
            	{else}
          <option value="{$releasecatdata[i].releasescatid}"
>{$releasecatdata[i].releasescatname}</option>
          
        	{/if}
        {/section}
      </select></td>
    </tr>
</table>
</form>


In IE 6.0 everything is working fine.
Please fix this bug, or tell me how to solve this.
<option selected>
is not working for me either

neither is
<option selected="selected">

looks like buggy O_o


what a shame IE handles it....
I also experienced this problem, and also managed to work around it.  I was
generating my html with php, but while trying to narrow down the problem,
noticed that if I saved the html from the broken page, then loaded that, it
worked fine.

Here is what I think happened: I loaded my form with non-validating xhtml 1.0
transitional, which didn't like my "selected" parameter, and so left most of my
selects at their default choice.  I then changed my html so that it validated,
but by then Firefox had cached my form choices, so when I reloaded the page they
stuck.  This continued until I loaded a new page (the saved copy), which loaded
fine.  After a while, I hit shift-reload on my original page instead of just
reload, and it in turn loaded fine.

In short, I don't think this is a bug, or if it is, the bug is that Firefox
remembers form choices a little too aggressively.  If the html has changed at
all, I think Firefox should forget the choices that had been made previously.
I too thought it was a parsing issue with Firefox but Shift+Refresh works.

I agree that Firfox is too agressive when it comes to remembering form
selections and should change to SELECTED if the html code changes.
I have found this to be the case when FireFox caches the data from the drop
down.  Personally, I think on reload of the page in question, the selected
option should take precidence over the cached value.

Shift-reload/refresh allows it to work, in FireFox (1.0), and in Camino
(2005030308 (v0.8+)) on Mac OS X 10.3.8.  For me at least.

Should this be listed as part of the "form manager"?
It seems like an issue with form manager, but it did the same thing to me (same
problem, same resolution - shift+F5), and I had form manager turned off. Seems
like some sort of partial caching issue, or a failure to totally deactivate form
manager.
Works with <option value="x" SELECTED>
With the new specs it should work with low case.
This poor bug has outlived its usefulness: it's in the wrong product and component, and if it was moved to the right one it's so old and so muddled with piling on it wouldn't get seen.

The original bug works for me with current trunk: every possible use of minimized "selected" works in everything from HTML 4.01 Transitional to XHTML 1.0 Strict mis-served as text/html. The only place it fails is in XHTML served as application/xhtml+xml, where it's a well-formedness error, so that probably wasn't what you meant. If you have an example which still fails to work, please file a new bug in the product Core, component Layout: Form Controls, and attach the example.

The way that selects don't change on refresh is History, not Form Manager, but it needs to be that way to let users hit the Back button without clobbering all the changes they've made to a form, so it's not only not this bug, it's not something that's likely to change.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.