I've got a function in JS that check all my checkboxes in a form:
function CheckAll(chk){
for (i = 0; i < chk.check.length; i++)
if (chk.All.checked==true){
chk.check[i].checked = true;
chk.check[i].disabled = true;
}
else {
chk.check[i].disabled = false;
chk.check[i].checked = false;
}
}
I've recently added some radio
buttons to my form, and my question is: will this function activate ALL my radio buttons too (I know that only one radio button can be selected, but I'm not sure how this works in a script like that..)?
Here you can find my form code:
<form name='MyForm'>
<b>This is my Simple Form</b></br>
</br>
<input type='radio' name='parameter' value='ONE' checked='checked' />ONE<br/>
<input type='radio' name='parameter' value='TWO' />TWO<br/>
<input type='radio' name='parameter' value='THREE' />THREE<br/>
<input type='radio' name='parameter' value='FOUR' />FOUR<br/>
<input type='radio' name='parameter' value='FIVE' />FIVE<br/>
<input type='radio' name='parameter' value='SIX' />SIX<br/>
<input type='radio' name='parameter' value='SEVEN' />SEVEN<br/>
<script>
document.write("</br>");
var count
var check_value = new Array()
check_value[0] = "001"
check_value[1] = "002"
check_value[2] = "003"
check_value[3] = "004"
for(count in check_value){
var checkbox = "<input type='checkbox' name='check' value='"+check_value[count]+"' />"
document.write(checkbox + check_value[count] + " ");
}
document.write("<input type='checkbox' name='All' value='All' onClick='CheckAll(document.MyForm);' /> All");
</script>
</br>
</br>
<input type=button value='Ok' onClick='foo(document.MyForm);'>
</form>
If this don't work as I want, how can I solve it?