SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: dynamic radio button
-
Jul 13, 2007, 08:45 #1
dynamic radio button
Hi Everyone,
Every time I create a radio button set and append it to an element in internet explorer I the radio button doesn't allow for it to be checked. It works fine in mozilla.
Here's a slimmed down example that produces the lock.
Code:function addRadio(e){ var i = document.createElement('input'); i.type = 'radio'; i.value = 1; document.getElementById(e).appendChild(i); }
Any suggestions,
Thanks
Nick
-
Jul 13, 2007, 10:28 #2
I figured out a solution.
Just create the input element as text and add a checked string.
This requires using innerHTML
IE
Code JavaScript:var checkStr = ''; if(someValue == someCheckedValue) checkStr = "checked"; someElement.innerHTML += '<input ' + checked + ' type="radio" value="1">';
But if anyone knows of a fix for adding the check to the element without using innerHTML and it doesn't lock the checkbox in IE please let me know.
Thanks,
Nick
Bookmarks