Cannot check a radio button in IE.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cruzan
    New Member
    • Dec 2010
    • 7

    Cannot check a radio button in IE.

    This code works in Firefox but not IE8. The innerHTML shows IE is not giving the radio buttons names making them uncheckable. Is there a workaround or fix? Thanks.
    Code:
    <script type="text/javascript">
    function main()
    {
      var bodyObj, radObj;
      bodyObj = document.getElementsByTagName("body")[0];
    
      radObj = document.createElement("input");
      radObj.type = "radio";
      radObj.name = "wr1";
      radObj.id = "wr1a";
      radObj.value = "a";
      bodyObj.appendChild(radObj);
    alert("name: "+radObj.name+", id: "+radObj.id+", value: "+radObj.value);
    
      radObj = document.createElement("input");
      radObj.type = "radio";
      radObj.name = "wr1";
      radObj.id = "wr1b";
      radObj.value = "b";
      bodyObj.appendChild(radObj);
    alert("name: "+radObj.name+", id: "+radObj.id+", value: "+radObj.value);
    
    alert(bodyObj.innerHTML);
    }
    </script>
    
    <html><body onload="main()">
    </body></html>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    IE is know to have some problems assigning certain properties correctly, try Element.setAttr ibute()

    Comment

    • Cruzan
      New Member
      • Dec 2010
      • 7

      #3
      Thanks. I tried setAttribute, but the name still isn't taking. I should've added that consequential nonfunctionalit y is actually happening more in IE7 rather than 8. 8 seems to maybe be working even without a name, but 7 is useless. Unfortunately, there are a bunch of computers that at least for the time being will continue to have IE7 only on them and it'll create a fair amount of inconvenience for a bunch of people if my app can't run on them.

      Comment

      Working...