Microsoft KB Archive/314279

= BUG: The FOR Attribute of the LABEL Object Resets Focus =

Article ID: 314279

Article Last Modified on 5/21/2007

-

APPLIES TO


 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer (Programming) 6 (SP1)

-



This article was previously published under Q314279



SYMPTOMS
When you click a label that is associated with a select box, the element that you selected in the select box is reset to the first element on the list.



RESOLUTION
You can only work around this problem in Internet Explorer 6 by using the onfocusin event. You can basically store the selected index into a temporary variable and reset the index to that variable when the select box obtains focus.

Use the following code as an example:   

//Set a temp expando to store the current selectedIndex function SelectOnFocusIn {   try {       var eSrc = window.event.srcElement; if (eSrc) eSrc.tmpIndex = eSrc.selectedIndex; }   catch (e) {       HandleError(e, false); } } //restore the selectedIndex function SelectOnFocus {   try {       var eSrc = window.event.srcElement; if (eSrc) eSrc.selectedIndex = eSrc.tmpIndex; }   catch (e) {       HandleError(e, false); } }

  

Citizenship Status:

 Alien Perm  Alien Temp  <OPTION VALUE=&quot;1&quot; SELECTED>Native </OPTION> <OPTION VALUE=&quot;2&quot;>Naturalized </OPTION> <OPTION VALUE=&quot;N&quot;>Not Indic. </OPTION> </SELECT>

</BODY> </HTML>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce the Problem
In following the drop-down list box, the third element is selected. If you click the Citizenship Status Label, the selected element in the drop-down list is reset to the first element. <BODY> Citizenship Status:</LABEL>

<SELECT NAME='test' ID='test'> <OPTION VALUE=&quot;3&quot; >Alien Perm <OPTION VALUE=&quot;4&quot;>Alien Temp <OPTION VALUE=&quot;1&quot; SELECTED >Native <OPTION VALUE=&quot;2&quot;>Naturalizd <OPTION VALUE=&quot;N&quot;>Not Indic. </SELECT>

</BODY> </HTML>

<div class="references_section">