Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.