Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
You can check a checkbox by updating its "checked" attribute.
Not sure what you mean by the POST array. As far as I'm aware, POST data is only sent to the server.
Code:
<script>
function checkAll(formId) {
var inputs = document.getElementById(formId).getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].getAttribute("type") == "checkbox") {
inputs[i].checked = true;
}
}
}
function uncheckAll(formId) {
var inputs = document.getElementById(formId).getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].getAttribute("type") == "checkbox") {
inputs[i].checked = false;
}
}
}
</script>
You'll need an id="whatever" attribute on the form in question, then pass this to the function.
Last edited by wayfarer07; 01-06-2009 at 09:55 AM..
Reason: fixed error in code
|