[thelist] Form generated in JS doesn't work in IE

kasimir-k kasimir.k.lists at gmail.com
Sun Jun 1 06:54:36 CDT 2008

> kasimir-k wrote:     
>> Yes, the options should be there allright but the select element is 
>> invisible to IE's form submission. To fix it, instead of this:
>>    mySelect.setAttribute('NAME','width');
>> try this:
>>    mySelect.name = 'width';

Chris Price scribeva in 2008-05-30 19:41:
> Nope, still doesn't work.

Well, it would if you were submitting the form :-)

But the problem lies in submission - namely in the onsubmit handler. And 
there are actually two problems for IE6.


   var myWidth = this.conWidth.value;

does not work unless the element has also an id "conWidth" (the name and 
id attributes must be the same). So you could do like this:

   var mySelect = document.createElement('select');
   mySelect.name = 'conWidth';
   mySelect.id = 'conWidth';

or you could access the elements like this:

   var myWidth = this.elements[2].value;

(Oddly this.elements['conWidth'].value does not work, so you must use 
numeric indices)

Second problem:

   myDiv.firstChild.nodeValue = '£' + myPrice;

IE6 does not see any childnodes for myDiv, so it can't set a value. Two 
ways around this:

   myDiv.innerHTML = '£' + myPrice;

or put an actual textnode in the div - empty space doesn't seem to cut 
it, but you can use

   <div id="showprice">&nbsp;</div>

Such a fascinating piece of software this IE6!


More information about the thelist mailing list