Forum Moderators: open
function resetForm(aomPreset, milPreset, posPreset){
var checkbox = document.volunteerform.elements["cb"];
if(window.confirm("Reset form input fields?")){
for(i=0; i < checkbox.length; i++){
if(aomPreset.charAt(i) == "1" ){checkbox[i].checked = true;}else{checkbox[i].checked = false;}
}
document.volunteerform.distance.value = milPreset;
document.volunteerform.postalcode.value = posPreset;
return true;
}else{
return false;
}
}
<ul>
<li><input name="aom[7]" class="cb" type="checkbox" value="1"<?php if ($aom[7] == "1") echo ' checked="checked"'; ?>/>Instruct the ignorant</li>
<li><input name="aom[8]" class="cb" type="checkbox" value="1"<?php if ($aom[8] == "1") echo ' checked="checked"'; ?>/>Counsel the doubtful</li>
<li><input name="aom[9]" class="cb" type="checkbox" value="1"<?php if ($aom[9] == "1") echo ' checked="checked"'; ?>/>Admonish sinners</li>
<li><input name="aom[10]" class="cb" type="checkbox" value="1"<?php if ($aom[10] == "1") echo ' checked="checked"'; ?>/>Bear wrongs patiently</li>
<li><input name="aom[11]" class="cb" type="checkbox" value="1"<?php if ($aom[11] == "1") echo ' checked="checked"'; ?>/>Forgive offenses willingly</li>
<li><input name="aom[12]" class="cb" type="checkbox" value="1"<?php if ($aom[12] == "1") echo ' checked="checked"'; ?>/>Comfort the afflicted</li>
<li><input name="aom[13]" class="cb" type="checkbox" value="1"<?php if ($aom[13] == "1") echo ' checked="checked"'; ?>/>Pray for the living and the dead</li>
</ul>
function resetForm(aomPreset, milPreset, posPreset){
var i,
checkbox = document.volunteerform.getElementsByTagName("input");
if (window.confirm("Reset form input fields?")) {
for(i = 0; i < checkbox.length; i++) {
if (checkbox[i].type == "checkbox" && checkbox[i].className == "cb") {
checkbox[i].checked = (aomPresent.charAt(i) == "1");
}
}
document.volunteerform.distance.value = milPreset;
document.volunteerform.postalcode.value = posPreset;
return true;
} else {
return false;
}
}
function resetForm(aomPreset, milPreset, posPreset){
var checkbox = $(".cb");
if(window.confirm("Reset form input fields?")){
for(i=0; i < checkbox.length; i++){
if(aomPreset.charAt(i) == "1" ){checkbox[i].checked = true;}else{checkbox[i].checked = false;}
}
document.volunteerform.distance.value = milPreset;
document.volunteerform.postalcode.value = posPreset;
return true;
}else{
return false;
}
}