# How to: toggle div if checkbox is checked

**URL:** <https://forum.kirupa.com/t/how-to-toggle-div-if-checkbox-is-checked/223884>\
**Category:** Uncategorized\
**Created:** [April 26, 2007, 1:40pm UTC](https://forum.kirupa.com/t/how-to-toggle-div-if-checkbox-is-checked/223884 "2007-04-26T13:40:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcav85](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@tcav85](https://forum.kirupa.com/u/tcav85)\
**Post date:** [April 26, 2007, 1:40pm UTC](https://forum.kirupa.com/t/how-to-toggle-div-if-checkbox-is-checked/223884/1 "2007-04-26T13:40:11Z")

</div>

I have a form for an image upload, when someone completes the form and uploads the image, a div is revealed with a mock loading bar to show the server side stuff is working.

However, what i need to be able to do is only reveal this div IF a ‘terms and conditions’ checkbox has been checked.

Currently if the checkbox is left blank, the div still reveals but a javascript popup tells the user they must check the checkbox, then when they go to upload again the div disappears again.

Any ideas?

my best try so far is:

```auto

<script type="text/javascript">
        //with thanks to Peter Müller
            window.onload = function() {
            if (document.uploadform.terms.checked == true)
{
                document.getElementById('clicker').onclick = function() {
                    document.getElementById('toggle').className = (document.getElementById('toggle').className == 'show') ? '' : 'show';
                }
            }
            return true;
}
        </script>

```
