I have HTML to display checkbox those checked via a loop:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://ift.tt/1Gufy1b"></script>
</head>
<body>
<form>
<input type="checkbox" name="bla_bla1" id="checkbox_1" onchange="getName();"/>
<input type="checkbox" name="bla_bla2" id="checkbox_2" onchange="getName();"/>
<input type="checkbox" name="bla_bla3" id="checkbox_3" onchange="getName();"/>
</form>
<span id="checkboxConfirm_1"></span>
<span id="checkboxConfirm_2"></span>
<span id="checkboxConfirm_3"></span>
<script>
function getName(){
for(i = 1; i<4; i++){
var a = "#checkbox_".concat(i.toString()) ;
var b = "#checkboxConfirm_".concat(i.toString());
if ((a).is(":checked")) {
$(b).text($(a).attr("name"));
} else {
$(b).text('');
}
}
}
</script>
</body>
</html>
But Javascript not work. Please help me resolve the problem.
Aucun commentaire:
Enregistrer un commentaire