Hey all,
Hit a bit of a snag here. I have a very Swiss cheese-like understanding of JavaScript and need some help with a form I've inherited for debugging purposes.
We've got three checkboxes: box1, box2, and box3.
We also have a fourth checkbox: box99 ("none of the above").
When box99 is checked, box1, box2, and box3 should clear.
This happens the first time, piece of cake. But when the user refreshes the page for whatever reason, the submit button disappears. Which, to me, sounds like the code is missing a line that would end things neatly.
(Don't ask me why the user would want to refresh a form. My boss's boss really wants to be able to refresh a form. Pick your battles and all that.)
Here's the code. It's JavaScript nestled in ColdFusion, but don't let that get in the way:
Thoughts, concerns?
Thanks,
Inger
Hit a bit of a snag here. I have a very Swiss cheese-like understanding of JavaScript and need some help with a form I've inherited for debugging purposes.
We've got three checkboxes: box1, box2, and box3.
We also have a fourth checkbox: box99 ("none of the above").
When box99 is checked, box1, box2, and box3 should clear.
This happens the first time, piece of cake. But when the user refreshes the page for whatever reason, the submit button disappears. Which, to me, sounds like the code is missing a line that would end things neatly.
(Don't ask me why the user would want to refresh a form. My boss's boss really wants to be able to refresh a form. Pick your battles and all that.)
Here's the code. It's JavaScript nestled in ColdFusion, but don't let that get in the way:
Code:
<script type="text/javascript">
function uncheckAll() {
var objCheckBoxes = document.step2.elements;
// var max = document.step2.ckbox.length;
if(!objCheckBoxes) {
return;
}
if (objCheckBoxes.box99.checked == true) {
// set the check value for all check boxes
for(var i = 1; i < 4; i++){
var cboxName = "box" + i;
//document.write (cboxName + '<br>');
if (objCheckBoxes[cboxName].type = "checkbox") {
objCheckBoxes[cboxName].checked = false;
}
}
}
document.getElementById('submitButton').style.display = 'block'
}
</script>
<form action="?fuseaction=survey.step3" method="post" name="step2">
<input type="checkbox" value="1" name="box1" onClick="document.getElementById('submitButton').style.display = 'block';" /> Company's <i>overall business decisions</i> (BDM)
<br />
<input type="checkbox" value="2" name="box2" onClick="document.getElementById('submitButton').style.display = 'block';" /> Company's <i>technical and technology-related decisions</i> (TDM)
<br />
<input type="checkbox" value="3" name="box3" onClick="document.getElementById('submitButton').style.display = 'block';" /> Company's <i>sales and marketing decisions</i> (S/M)
<br />
<br />
<input type="checkbox" value="8" name="box99" onClick="document.getElementById('submitButton').style.display = 'block';uncheckAll();" /> None of the above
<br />
<input type="submit" id="submitButton" value="> > >" style="display: none;" />
</form>
Thoughts, concerns?
Thanks,
Inger