Jump to content

using if statements with checkboxs


errcricket

Recommended Posts

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.

 

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

 

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

 

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


<input type="checkbox" onclick="???; name="x1" value="<?php if(isset($_POST['x1'])) echo 'checked="checked"';?>"> 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

Link to comment
https://forums.phpfreaks.com/topic/186279-using-if-statements-with-checkboxs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.