I've got a web form with some elements that I want to be hidden until a checkbox is checked. The elements that need hiding are within a DIV (called F1div) and the checkbox has this onclick code:
onclick="modifydiv(this.checked,'F1div')"
Which runs this code:
<script>
function modifydiv(val,divname)
{
oDiv = eval("document.all."+divname);
if(val)
{
oDiv.style.visibility = "visible";
oDiv.style.display = "inline";
}
else
{
oDiv.style.visibility = "hidden";
oDiv.style.display = "none";
}
}
</script
Now this works OK and when the check box is checked or unchecked the div is shown or hidden.
I would like though the form at page load to either show or hide the div depending on the value of the check box at page load (as the checkbox is bound to a boolean database field) too but aren't sure how to do this.
I want this because when the visitor first visits the page the checkbox is unchecked (so I can hide the div at pageload) but if they check the box and submit the form (saving the data to the database) and then later come back to the page I want it to look at the value of the checkbox and either show or hide the div accordingly.
Any ideas?
Thanks.



Reply With Quote

Bookmarks