Forum Moderators: open
So I have this code and when I check a box the alert() fires then in the text box I get undefined. If I click all three I get undefined,undefined,undefined, So where are my var's.
================================
function getchecked() {
alert("SSS");
var newtxt = '';
var chkbx = document.getElementsByTagName('input');
for(var i = 0; i < chkbx.length; i ++) {
if(chkbx[i].type == 'checkbox' && chkbx[i].checked === true) {
if(newtxt.length !== 0) {
newtxt += ',';
}
newtxt += chkbx.innerHTML;
}
}
document.formName.marktext.value = newtxt;
}
</script>
<body>
<form name="formName">
<input name="marktext" type="text" value="" size="120">
<br>
<input type="checkbox" name="input" value = "WORD" onclick="getchecked()">Word<br>
<input type="checkbox" name="input" onclick="getchecked(this,'Type')">Type<br>
<input type="checkbox" name="input" onclick="getchecked(this,'Other')" value="S">Other<br>
</form>
==============================
Thanks
Bobby