<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Bug when creating select options using innerHTML in IE</title>
	<atom:link href="http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/feed/" rel="self" type="application/rss+xml" />
	<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/</link>
	<description>the personal blog of Stuart Colville covering modern web development techniques and best practices</description>
	<lastBuildDate>Thu, 09 Feb 2012 02:58:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Mrinal</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-64138</link>
		<dc:creator>Mrinal</dc:creator>
		<pubDate>Mon, 24 Mar 2008 14:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-64138</guid>
		<description>I finally found the solution for &#039;bug in select option in IE&#039;  specially for the values return by Ajax 
the following function will work
function setText(xmlHttp.responseText)
{
var resText=xmlHttp.responseText;
  document.getElementbyId(&quot;select_element&quot;).innerHTML=&quot;&quot;+resText;
document.getElementbyId(&quot;select_element&quot;).outerHTML=document.getElementbyId(&quot;select_element&quot;).outerHTML;
}

Here xmlHttp.responseText is the response from ajax funtion which is not shown here.</description>
		<content:encoded><![CDATA[<p>I finally found the solution for &#8216;bug in select option in IE&#8217;  specially for the values return by Ajax<br />
the following function will work<br />
function setText(xmlHttp.responseText)<br />
{<br />
var resText=xmlHttp.responseText;<br />
  document.getElementbyId(&#8220;select_element&#8221;).innerHTML=&#8221;"+resText;<br />
document.getElementbyId(&#8220;select_element&#8221;).outerHTML=document.getElementbyId(&#8220;select_element&#8221;).outerHTML;<br />
}</p>
<p>Here xmlHttp.responseText is the response from ajax funtion which is not shown here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Colville</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-63945</link>
		<dc:creator>Stuart Colville</dc:creator>
		<pubDate>Sat, 02 Feb 2008 20:29:30 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-63945</guid>
		<description>@James: I think your last comment (removed) got eaten by something. Feel free to drop me a line and I&#039;ll update your comment.</description>
		<content:encoded><![CDATA[<p>@James: I think your last comment (removed) got eaten by something. Feel free to drop me a line and I&#8217;ll update your comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-63935</link>
		<dc:creator>James</dc:creator>
		<pubDate>Fri, 01 Feb 2008 19:29:03 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-63935</guid>
		<description>I&#039;ve worked around the problem using the following: 
        var sourceList = document.getElementByID(&quot;mySelectBox&quot;);
        var newInnerHTML = sourceList.parentNode.innerHTML;
        var bracketPos = newInnerHTML.indexOf(&quot;&gt;&quot;)+1;
        newInnerHTML = newInnerHTML.substring(0, bracketPos)+ SourceOptionsList+ &quot;&quot;;
            sourceList.parentNode.innerHTML =   newInnerHTML;

I find everything before the first &#039;&gt;&#039;, keep that part, and then replace everything after it with my new list of options, and the .

This, of course, will clobber the sourceList variable, as you&#039;re replacing your referenced select object with something completely new.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve worked around the problem using the following:<br />
        var sourceList = document.getElementByID(&#8220;mySelectBox&#8221;);<br />
        var newInnerHTML = sourceList.parentNode.innerHTML;<br />
        var bracketPos = newInnerHTML.indexOf(&#8220;&gt;&#8221;)+1;<br />
        newInnerHTML = newInnerHTML.substring(0, bracketPos)+ SourceOptionsList+ &#8220;&#8221;;<br />
            sourceList.parentNode.innerHTML =   newInnerHTML;</p>
<p>I find everything before the first &#8216;&gt;&#8217;, keep that part, and then replace everything after it with my new list of options, and the .</p>
<p>This, of course, will clobber the sourceList variable, as you&#8217;re replacing your referenced select object with something completely new.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ralph</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-63882</link>
		<dc:creator>Ralph</dc:creator>
		<pubDate>Tue, 15 Jan 2008 18:41:01 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-63882</guid>
		<description>As noted by most, there isn&#039;t one nice clean solution other than using the Option() constructor.

The bug is tracked here:
http://webbugtrack.blogspot.com/2007/08/bug-274-dom-methods-on-select-lists.html

But the &quot;best&quot; workaround is not mentioned.</description>
		<content:encoded><![CDATA[<p>As noted by most, there isn&#8217;t one nice clean solution other than using the Option() constructor.</p>
<p>The bug is tracked here:<br />
<a href="http://webbugtrack.blogspot.com/2007/08/bug-274-dom-methods-on-select-lists.html" rel="nofollow">http://webbugtrack.blogspot.com/2007/08/bug-274-dom-methods-on-select-lists.html</a></p>
<p>But the &#8220;best&#8221; workaround is not mentioned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-63671</link>
		<dc:creator>George</dc:creator>
		<pubDate>Tue, 06 Nov 2007 19:01:45 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-63671</guid>
		<description>There is a big problem with selectBox.outerHTML = selectBox.outerHTML;

Any DOM-added event handlers associated with the control (via $addHandler()) will be wiped out.

Yes, this sucks.</description>
		<content:encoded><![CDATA[<p>There is a big problem with selectBox.outerHTML = selectBox.outerHTML;</p>
<p>Any DOM-added event handlers associated with the control (via $addHandler()) will be wiped out.</p>
<p>Yes, this sucks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LongStone</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-62687</link>
		<dc:creator>LongStone</dc:creator>
		<pubDate>Fri, 05 Oct 2007 21:37:53 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-62687</guid>
		<description>I finally tried the &quot;paste over&quot; for outerHTML worked in this instance...this is after trying normal DOM methods (IE won&#039;t render at all), used it before (create all my elements with DOM compliant code then extract all the HTML for an IE cludge)

tried:
 document.createElement(HTMLString); then append -&gt; parent.appendChild(newChild);
then adding inputOption = new Option(vars)
(IE sets first element as selected, can&#039;t change it via element.selected or element.defaultSelected )

not sure if this is consistant (like anything is in IE except errors)

If you want IE to render the HTML properly for display purposes use innerHTML

If you want IE to be able to access the new element in the DOM (like $() or getElementByID) use 
 document.createElement(HTMLString); then append -&gt; parent.appendChild(newChild);   BTW, you&#039;ll have to do this for all your sub elements too :-/

remember with the above method IE will only accept the outer element, ie if HTMLString = 

ONLY the select will be out put

Dan, re. &quot;The IE team is not lazy...they are just incompetent&quot;  They should be gang raped by a pack of rabid baboons. Time for a class action lawsuit and bill back to M$ for all the wasted time doing work arounds lol.</description>
		<content:encoded><![CDATA[<p>I finally tried the &#8220;paste over&#8221; for outerHTML worked in this instance&#8230;this is after trying normal DOM methods (IE won&#8217;t render at all), used it before (create all my elements with DOM compliant code then extract all the HTML for an IE cludge)</p>
<p>tried:<br />
 document.createElement(HTMLString); then append -&gt; parent.appendChild(newChild);<br />
then adding inputOption = new Option(vars)<br />
(IE sets first element as selected, can&#8217;t change it via element.selected or element.defaultSelected )</p>
<p>not sure if this is consistant (like anything is in IE except errors)</p>
<p>If you want IE to render the HTML properly for display purposes use innerHTML</p>
<p>If you want IE to be able to access the new element in the DOM (like $() or getElementByID) use<br />
 document.createElement(HTMLString); then append -&gt; parent.appendChild(newChild);   BTW, you&#8217;ll have to do this for all your sub elements too :-/</p>
<p>remember with the above method IE will only accept the outer element, ie if HTMLString = </p>
<p>ONLY the select will be out put</p>
<p>Dan, re. &#8220;The IE team is not lazy&#8230;they are just incompetent&#8221;  They should be gang raped by a pack of rabid baboons. Time for a class action lawsuit and bill back to M$ for all the wasted time doing work arounds lol.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zig</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-37685</link>
		<dc:creator>zig</dc:creator>
		<pubDate>Fri, 04 May 2007 12:02:40 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-37685</guid>
		<description>I have used the outerHTML-trick and i am having problems with the options[n].selected-property. It seem to be unassigned. 

It doesn&#039;t seem as if that property is properly refreshed.</description>
		<content:encoded><![CDATA[<p>I have used the outerHTML-trick and i am having problems with the options[n].selected-property. It seem to be unassigned. </p>
<p>It doesn&#8217;t seem as if that property is properly refreshed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-23686</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Fri, 26 Jan 2007 18:45:59 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-23686</guid>
		<description>The quick workaround posted above will work with just a little bit more of a hack.  
&lt;code&gt;
if(document.all)
{
opts = &#039;&lt;option&gt;truncatethis&lt;/option&gt;&#039; + opts;
}
objTargetSelect.innerHTML = opts;
if(document.all) { // Or any IE testing
   objTargetSelect.outerHTML = objTargetSelect.outerHTML;
}
&lt;/code&gt;
Pretty cheesy to have to do something like this, but it works</description>
		<content:encoded><![CDATA[<p>The quick workaround posted above will work with just a little bit more of a hack.<br />
<code><br />
if(document.all)<br />
{<br />
opts = '&lt;option&gt;truncatethis&lt;/option&gt;' + opts;<br />
}<br />
objTargetSelect.innerHTML = opts;<br />
if(document.all) { // Or any IE testing<br />
   objTargetSelect.outerHTML = objTargetSelect.outerHTML;<br />
}<br />
</code><br />
Pretty cheesy to have to do something like this, but it works</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-16189</link>
		<dc:creator>dan</dc:creator>
		<pubDate>Tue, 14 Nov 2006 11:52:50 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-16189</guid>
		<description>A 7 yr old bug. The IE team is not lazy, as claimed by some ignorant people - they are just incompetent. Microsoft should stop browser development and instead focus on securing their not-surprisingly buggy OS.</description>
		<content:encoded><![CDATA[<p>A 7 yr old bug. The IE team is not lazy, as claimed by some ignorant people &#8211; they are just incompetent. Microsoft should stop browser development and instead focus on securing their not-surprisingly buggy OS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bram</title>
		<link>http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/comment-page-1/#comment-15164</link>
		<dc:creator>Bram</dc:creator>
		<pubDate>Wed, 08 Nov 2006 14:59:19 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/07/19/bug-when-creating-select-options-using-innerhtml-in-ie/#comment-15164</guid>
		<description>@GavrocheLeGnou:
This wont work... The first OPTION-element gets truncated (as said in the original article) so although it seems it works (no errors, filled options) you&#039;re missing your first OPTION.</description>
		<content:encoded><![CDATA[<p>@GavrocheLeGnou:<br />
This wont work&#8230; The first OPTION-element gets truncated (as said in the original article) so although it seems it works (no errors, filled options) you&#8217;re missing your first OPTION.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

