Microsoft KB Archive/239657: Difference between revisions

From BetaArchive Wiki
m (Text replacement - ">" to ">")
m (Text replacement - """ to """)
 
Line 67: Line 67:
This is a generic example of the code used in such an instance:
This is a generic example of the code used in such an instance:
<pre class="codesample">
<pre class="codesample">
<FORM NAME=&quot;myform&quot;>
<FORM NAME="myform">
<SELECT NAME=&quot;widget&quot; SIZE=&quot;3&quot; MULTIPLE>
<SELECT NAME="widget" SIZE="3" MULTIPLE>
<OPTION>111111</OPTION>
<OPTION>111111</OPTION>
<OPTION>222222</OPTION>
<OPTION>222222</OPTION>
Line 79: Line 79:
<OPTION>999999</OPTION>
<OPTION>999999</OPTION>
</SELECT>
</SELECT>
<INPUT TYPE=&quot;BUTTON&quot; VALUE=&quot;Crash or not&quot; ONCLICK=&quot;RemoveSelectedItems()&quot;>
<INPUT TYPE="BUTTON" VALUE="Crash or not" ONCLICK="RemoveSelectedItems()">
</FORM>
</FORM>
                 </pre>
                 </pre>
Here is the script code to remove the selected items that causes GPF.
Here is the script code to remove the selected items that causes GPF.
<pre class="codesample"><SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<pre class="codesample"><SCRIPT LANGUAGE="JavaScript">


   function RemoveSelectedItems()
   function RemoveSelectedItems()
Line 100: Line 100:
</SCRIPT>
</SCRIPT>
                 </pre>
                 </pre>
To reproduce the problem, you need to select at least four items in this sample and then click the &quot;'''Crash or not'''&quot; button.<br />
To reproduce the problem, you need to select at least four items in this sample and then click the "'''Crash or not'''" button.<br />
<br />
<br />
The root of the problem is removing the selected items. The workaround is to deselect the items, and save the list of selections in a temporary array.<br />
The root of the problem is removing the selected items. The workaround is to deselect the items, and save the list of selections in a temporary array.<br />
<br />
<br />
The following is an example of how this might be coded:
The following is an example of how this might be coded:
<pre class="codesample"><SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<pre class="codesample"><SCRIPT LANGUAGE="JavaScript">


   function RemoveSelectedItems()
   function RemoveSelectedItems()

Latest revision as of 13:47, 21 July 2020

Knowledge Base


FIX: Removing Non-Visible Items from an HTML SELECT Box Causes General Protection Fault (GPF)

Article ID: 239657

Article Last Modified on 5/11/2006



APPLIES TO

  • Microsoft Internet Explorer 5.0



This article was previously published under Q239657

SYMPTOMS

When removing items from a <SELECT MULTIPLE> tag, removing more selected items than are viewable at once in the select box causes a GPF.

RESOLUTION

Create a temporary list of the selected elements, deselect all of them, and then remove the elements per the temporary list.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Internet Explorer 5.01.

MORE INFORMATION

This is a generic example of the code used in such an instance:

<FORM NAME="myform">
<SELECT NAME="widget" SIZE="3" MULTIPLE>
<OPTION>111111</OPTION>
<OPTION>222222</OPTION>
<OPTION>333333</OPTION>
<OPTION>444444</OPTION>
<OPTION>555555</OPTION>
<OPTION>666666</OPTION>
<OPTION>777777</OPTION>
<OPTION>888888</OPTION>
<OPTION>999999</OPTION>
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Crash or not" ONCLICK="RemoveSelectedItems()">
</FORM>
                

Here is the script code to remove the selected items that causes GPF.

<SCRIPT LANGUAGE="JavaScript">

   function RemoveSelectedItems()
   {
      var i

      for ( i = document.myform.widget.options.length - 1; i >= 0; --i )
      {
         if (  document.myform.widget.options[ i ].selected )
         {
           document.myform.widget.options[ i ] = null
         }
      }
   }

</SCRIPT>
                

To reproduce the problem, you need to select at least four items in this sample and then click the "Crash or not" button.

The root of the problem is removing the selected items. The workaround is to deselect the items, and save the list of selections in a temporary array.

The following is an example of how this might be coded:

<SCRIPT LANGUAGE="JavaScript">

   function RemoveSelectedItems()
   {
      var i, cnt
      var mywidget
      var selArray = new Array()

      myWidget= document.myform.widget

      for ( i = myWidget.options.length - 1; i >= 0; --i )
      {
         if (  myWidget.options[ i ].selected )
         {
            myWidget.options[i].selected = false
            selArray[selArray.length]=i
            //document.myform.widget.options[ i ]=null
         }
      }

      for ( i =  0 ; i <= selArray.length; i++ )
      {
         myWidget.options[ selArray[i] ]=null
      }
   }

</SCRIPT>
                

REFERENCES

For additional information about issues with Select boxes, please click the article number below to view the article in the Microsoft Knowledge Base:

237831 PRB: Problem Adding New Option to Select Box in Another Frame in Internet Explorer 5


For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

Keywords: kbbug kbdhtml kbfaq kbfix KB239657