Memilih Item Check
<html>
<head>
<title>Demo Check/Uncheck</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
/**
* field Kontrol pemicu
* list Elemen list
*/
function check(field, list) {
if (field.checked) {
checkUncheck(list, 1);
} else {
checkUncheck(list, 0);
}
}
// Check/Uncheck field berdasar value
function checkUncheck(field, value) {
var len = field.length;
for (i = 0; i < len; i++) {
field[i].checked = value;
}
}
//-->
</script>
<form action="#" method="post">
<input type="checkbox" onClick="check(this, list)" />
Check/Uncheck All <hr />
<input type="checkbox" name="list" value="item_1" />Item 1<br />
<input type="checkbox" name="list" value="item_2" />Item 2<br />
<input type="checkbox" name="list" value="item_3" />Item 3<br />
<input type="checkbox" name="list" value="item_4" />Item 4<br />
<input type="checkbox" name="list" value="item_5" />Item 5<br />
</form>
</body>
</html>
No comments:
Post a Comment