dynamically added radio buttons onclick event not working ?

Posted by Anil Namde on Stack Overflow See other posts from Stack Overflow or by Anil Namde
Published on 2010-03-19T06:11:18Z Indexed on 2010/03/19 7:11 UTC
Read the original article Hit count: 237

Filed under:
|

I am trying following, 1. Get response using Ajax from the users selection which returns me the list of the radio buttons attributes as 2. Once i get the attribute list i am creating the radio buttons using createElement() 3. Then i am attaching the event to the radio button for onclick buttons. 4. Then i add element to the DOM using appedChild

The below is code for adding radio button (for IE)

var radio = '<input ';
radio += 'type ="radio" ';
radio += 'id="' + id + '" ';
radio += 'value="" ';
radio += '/>';
radioButton = document.createElement(radio);
radioButton.onClick = function(){alert('this is test')}
ele.appendChild(radioButton);
ele.innerHTML += 'none' + '<br/>';

Now in all this when i am adding the radio button to the DOM onclick is not working and i don't understand why ?

Thanks all

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom