I create several input elements like using this function (with a different iID argument each time):
function createResponseItem(iID) {
var newInput = document.createElement('input');
newInput.setAttribute('id','response-' + iID);
newInput.setAttribute('type','radio');
newInput.setAttribute('onclick','responseClick(event)');
myDiv.appendChild(newInput);
}
and this works fine, but if I click on one of these inputs, and then, in the responseClick(event) function, I try to query the id of the input in question, like this:
function responseClick(evt) {
alert(evt.target.id);
}
What my alert shows is:
response-function toString() { [native code] }
but that's no use in identifying which of the (dynamically created) inputs I clicked on.
What am I doing wrong here?
JAS
function createResponseItem(iID) {
var newInput = document.createElement('input');
newInput.setAttribute('id','response-' + iID);
newInput.setAttribute('type','radio');
newInput.setAttribute('onclick','responseClick(event)');
myDiv.appendChild(newInput);
}
and this works fine, but if I click on one of these inputs, and then, in the responseClick(event) function, I try to query the id of the input in question, like this:
function responseClick(evt) {
alert(evt.target.id);
}
What my alert shows is:
response-function toString() { [native code] }
but that's no use in identifying which of the (dynamically created) inputs I clicked on.
What am I doing wrong here?
JAS