SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict y_oda2002's Avatar
    Join Date
    May 2005
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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);
    }
    Whenever the element is appended in IE it doesn't allow itself to be selected.

    Any suggestions,

    Thanks

    Nick
    Nicholas Rhodes
    Asgard Development
    http://www.asgard-dev.com

  2. #2
    SitePoint Addict y_oda2002's Avatar
    Join Date
    May 2005
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    Nicholas Rhodes
    Asgard Development
    http://www.asgard-dev.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •