# Using if statements with checkboxs

**URL:** <https://forum.kirupa.com/t/using-if-statements-with-checkboxs/302267>\
**Category:** Uncategorized\
**Created:** [December 24, 2009, 6:59pm UTC](https://forum.kirupa.com/t/using-if-statements-with-checkboxs/302267 "2009-12-24T18:59:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![errcricket](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@errcricket](https://forum.kirupa.com/u/errcricket)\
**Post date:** [December 24, 2009, 6:59pm UTC](https://forum.kirupa.com/t/using-if-statements-with-checkboxs/302267/1 "2009-12-24T18:59:05Z")

</div>

Greetings,

I have several checkboxes - and if one is chosen, I would like to display certain radio buttons.  
I have a system that works using javascript and visibility options, but each set of radio buttons take up a line of space whether they are visible or not. So when nothing is selected there is this empty massive space.

```auto

.
.
<div id="myGroup8" style="visibility: hidden;"> [COLOR=#000000][COLOR=#0000bb]<?php [/COLOR][COLOR=#007700]include ([/COLOR][COLOR=#dd0000]"x1.html"[/COLOR][COLOR=#007700]); [/COLOR][COLOR=#0000bb]?>[/COLOR][/COLOR] </div>
<div id="myGroup9" style="visibility: hidden;"> [COLOR=#000000][COLOR=#0000bb]<?php [/COLOR][COLOR=#007700]include ([/COLOR][COLOR=#dd0000]"x2.html"[/COLOR][COLOR=#007700]); [/COLOR][COLOR=#0000bb]?>[/COLOR][/COLOR] </div>
.
.
<form><input type="checkbox" onclick="toggle(this, 'myGroup7')" setVisibility('myGroup7','collapse'); name="x1" value="[COLOR=#000000][COLOR=#0000bb]<?php [/COLOR][COLOR=#007700]if(isset([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'x1'[/COLOR][COLOR=#007700]])) echo [/COLOR][COLOR=#dd0000]'checked="checked"'[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000bb]?>[/COLOR][/COLOR]"> x1
<input type="checkbox" onclick="toggle(this, 'myGroup8')" setVisibility('myGroup8','collapse'); name="x2" value="[COLOR=#000000][COLOR=#0000bb]<?php [/COLOR][COLOR=#007700]if(isset([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'x2'[/COLOR][COLOR=#007700]])) echo [/COLOR][COLOR=#dd0000]'checked="checked"'[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000bb]?>[/COLOR][/COLOR]"> x2</form>
.
.

```

I would prefer using php to accomplish this task - something like below (but that actually works)…

```auto

if(isset($_POST['x1']))
   include ("x1.html");

<input type="checkbox" onclick="???; name="x1" value="[COLOR=#000000][COLOR=#0000bb]<?php [/COLOR][COLOR=#007700]if(isset([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'x1'[/COLOR][COLOR=#007700]])) echo [/COLOR][COLOR=#dd0000]'checked="checked"'[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000bb]?>[/COLOR][/COLOR]"> x1

```

This is not going into a database, these actions must occur on the onclick (i.e. not on a submit button), and I would like the space to expand/contract depending on checkbox states. Any assistance is greatly appreciated.

- c
