javascript - Dynamically created radio inputs don't check in IE7 -


I came across a strange IE-specific error. It appears that when documents create radio inputs with .createElement, the resulting widgets do not respond to clicks when you click on them, they are grayed out for each other, but they are not checked in FF3 Expected works, but not IE 7. Any idea what's going on?

  & lt; Html & gt; & Lt; Body & gt; & Lt; Form & gt; & Lt; Div id = "foo" & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; Script & gt; Var foo = document.getElementById ('foo'); Var t = document.createElement ('Input'); T.type = 'radio'; T. Name = 'idiot'; Var f = document.createElement ('Input'); F.type = 'radio'; F.name = 'Fool'; Foo.appendChild (t); Foo.appendChild (f); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

For any reason, by creating radio buttons in this way, does not work .

A solution that seems to work (according to the article found) is done:

  var r; Try {// it works in IE r = document.createElement ('& lt; input type = "radio" name = "foo1" /> gt;'); } Hold (mistake) {// for everyone = document.createElement ('input'); } R.setAttribute ('type', 'radio'); R.setAttribute ('name', 'foo1');  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -