i have a javascript function that should select all the checkboxes when a link is clicked. however, it cannot work when there is only 1 checkbox. the following is my code. is there anything that i have done wrong? Thanks.
<head>
<script language=”JavaScript” type=”text/JavaScript”>
<!–
function checkAll(field) {
[INDENT] for (i = 0; i < field.length; i++) {[/INDENT]
[INDENT] [INDENT] field[i].checked = true;[/INDENT][/INDENT]
[INDENT] } [/INDENT]
}
//–>
</script>
</head>
<body>
<form name=”form1″>
Select: <a href=”javascript:checkAll(document.form1.checkbox)”><u>All</u></a>
<%
[INDENT]for (int i = 0; i < 1; i++) { %>[/INDENT]
[INDENT][INDENT]<br><input type=”checkbox” name=”checkbox” value=”checkbox”>[/INDENT][/INDENT]
<% } %>
</form>
</body>