View Single Post
Old 24-Feb-2007, 12:10 AM   #1 (permalink)
Sangeetha
Fixed Error!
 
Sangeetha's Avatar

Posts: 139
Location: Chennai
Join Date: Feb 2007
Rep Power: 2 Sangeetha is on a distinguished road

IM:
Default Get element ID from a clicked checkbox into numeric variable

Question
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;
}
Sangeetha is offline   Reply With Quote