PHP/HTML - How to display a single column of check boxes in 2 or 3 columns?

Chris B

New member
There is a simple add-on you can use.
If you are counting the number of checkboxes that go down, limit it to, let's say, 10.
So you will have (again just an example) 30 checkboxes, 10 in each row.
Let's say the number of checkboxes are represented by the variable $amount.
if($amount = 10 || $amount = 20){
// HTML for new column here
}
Therefore, when the check box reaches 10, it will create a new row, making a total of two rows. And it will also trigger when it reaches 20, creating the third row.
Good Luck!
If you need further assistance/advice about understanding what I am talking about, feel free to contact me.
 
I have a list of products that the user can select by checking the appropriate check boxes. Originally this worked fine when the list of products is short. Now it's stretching to two pages and I want to shorten them down to one page using 2 or three columns. How would I do that? Thanks.

Below is the current table, and table data code that dislays a single list of check boxes:

<table width="100%" cellpadding="0" cellspacing="0" class="tpf_tablerow">
<tr class="tpf_rowdotted">
<td valign="top" nowrap="nowrap">
<strong><?php echo JText::_('PRODUCTS');?></strong> :
</td>
<td >
<?php
for ($i=0, $n=count($products); $i < $n; $i++) {
$prod = $products[$i];
$is_checked='';

if(count($parm) > 0) /* $parm is a function parameter received
{
if (in_array((int)$prod->id, $parm, true))
{
$is_checked ="checked";
}
}
?>
<input type="checkbox" name="prodid[]" id="prodid[]" value="<?php echo $prod->id?>" <?php echo $is_checked;?>/> <?php echo $prod->products ."<br/>" ;
}
?>

</td>
</tr>
 
There is a simple add-on you can use.
If you are counting the number of checkboxes that go down, limit it to, let's say, 10.
So you will have (again just an example) 30 checkboxes, 10 in each row.
Let's say the number of checkboxes are represented by the variable $amount.
if($amount = 10 || $amount = 20){
// HTML for new column here
}
Therefore, when the check box reaches 10, it will create a new row, making a total of two rows. And it will also trigger when it reaches 20, creating the third row.
Good Luck!
If you need further assistance/advice about understanding what I am talking about, feel free to contact me.
 
Back
Top