Javascript: transmit variable between method

wantime
wantime used Ask the Experts™
on
hello all,

i have create a check box group, when one of them is checked, the  id of this checkbox should be showed in a messagebox. The problem i met is that i don't know how to transmit the id between the method.

following are the source codes.

any suggestion?

thanks.

wantime
<html>
<head>
<script language="JavaScript">
function cbVariableTest() {  
var mTable = document.getElementById('dy');
   for (var i = 0; i < 3; i++) {
	row = mTable.insertRow(-1);		 
        cb = row.insertCell(0);                                   
        cb.innerHTML = '<input type="checkbox" id = i  checked onclick="checkIt(i);"></input>';                                             				
	}
}

function checkIt(checkBoxId) {
	alert('CheckBox Id is: ' + checkBoxId);
}
  
</script>
</script>
</head>
<body>
<table id="dy">
</table>
<input type="button" value = "Create CheckBox Group" onclick="cbVariableTest()"/>
</body>
</html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

try this one:
cb.innerHTML = '<input type="checkbox" id = i  checked onclick="checkIt('+i+');"></input>';                                             				
	

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial