Get element ID from a clicked checkbox into numeric variable
I have a form with 200 plus checkboxes.
When the checkbox is checked onClick passes (this) to a Javascript function.
I need to get the element array ID of the just checked checkbox into a numeric variable.
The following routine never finds a match. The value returned in thisCheckID is blank when I send it to a text field.
function getcheckboxid(formobj)
{
var checkboxname=formobj.name;
var checks = document.getElementsByTagName("INPUT");
var len = checks.length;
var thisCheck, thisCheckID;
for (var i = 0; i < len; i++)
{
if (checks[i].name == checkboxname)
{
thisCheckID = checks[i].id;
}
document.form1.text1.value=thisCheckID;
}