Forum Moderators: coopster

Message Too Old, No Replies

Regarding a long list of checkboxes

         

H2O_aa

12:16 am on Dec 3, 2005 (gmt 0)

10+ Year Member



This is very hard for me to explain so I hope I am not confusing you.

I have a list of checkboxes like this:

<p><strong>Majors</strong></p>
<p><input type="checkbox" name="major[]" value="Engineering">Engineering</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5%">&nbsp;</td>
<td width="95%"><input type="checkbox" name="major[]" value="Computer Science">Computer Science<br>
<input type="checkbox" name="major[]" value="Mechanical">Mechanical<br>
<input type="checkbox" name="major[]" value="Manufacturing">Manufacturing<br>
</td>
</tr>
</table>

<p><input type="checkbox" name="major[]" value="Business Administration">Business Administration<br>
<input type="checkbox" name="major[]" value="Art">Art
</p>

Notice that there is a sub group of checkboxes under Engineering and it is indented (by using a table) so that people know that it's part of Engineering. And notice that I named them as an array (major[]). Now this list will be part of a form. So people fill out the form and press submit, then a copy of what they filled out will be emailed to them. I want to use foreach() to list the checkbox values out. Something like:

foreach ($major as $value) {
print $value . '<br>';
}

But I want to keep the sub group of checkboxes under Enginerring indented, if they are selected. And I don't know how to do that. Can anyone shine some lights here on what I want to do?

I would like to name the checkboxes as an array (major[]) because my real list contains a very long list of checkboxes of major. If I named them individually, it would be very messy.

Thanks!

willybfriendly

12:30 am on Dec 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are sending html email, assign a tag and a CSS margin, or, prepend a couple of &nbsp;'s to them

foreach ($major as $value) {
print "&nbsp;&nbsp;".$value . '<br>';
}

WBF

H2O_aa

12:46 am on Dec 3, 2005 (gmt 0)

10+ Year Member



willybfriendly,

You code will put some spaces in front of all the values. I just want spaces in front of the sub group of checkboxes (computer science, mechanical, manufacturing), if they are selected.

jatar_k

9:54 pm on Dec 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well you need to find a way to identify them individually.

How many are there that need to be indented? if there aren't many then do them by name. If there are a large number out of an even larger number

then don't worry about indenting or find a different solution