troubleshooting Question

Javascript: transmit variable between method

Avatar of wantime
wantime asked on
JavaScript
1 Comment1 Solution196 ViewsLast Modified:
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

ASKER CERTIFIED SOLUTION
dr_Pitter

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros