Avatar of wantime
wantime
 asked on

Javascript: transmit variable between method

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

JavaScript

Avatar of undefined
Last Comment
dr_Pitter

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dr_Pitter

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy