Javascript: transmit variable between method

wantime used Ask the Experts™
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?


<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);
<table id="dy">
<input type="button" value = "Create CheckBox Group" onclick="cbVariableTest()"/>

Open in new window

Watch Question

Do more with

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

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