1
I have lots of checkboxes to display, each with a different label, in a row and column format. I've got the row and column problem solved but I want to get away from having to do the standard 3 or 4 lines of code to do each checkbox like this:
$tray_locale = new XoopsFormElementTray("");
$locale = new XoopsFormCheckBox("","Locale",!$opt[$i++]);
$locale->addOption("0","Locale");
$tray_locale->AddElement($locale);
$tray_buildings = new XoopsFormElementTray("");
$buildings = new XoopsFormCheckBox("","Buildings",!$opt[$i++]);
$buildings->addOption("0","Buildings");
$tray_buildings->AddElement($buildings);
$tray_Businesses = new XoopsFormElementTray("");
$Businesses = new XoopsFormCheckBox("","Businesses",!$opt[$i++]);
$Businesses->addOption("0","Businesses");
$tray_Businesses->AddElement($Businesses);
... up to 40 or so checkboxes.
I would like to put the name of each checkbox in a DB table and create them on the fly into a template like this:
$sql = 'SELECT name FROM '.$xoopsDB->prefix('gis_checkbox').'';
$result = $xoopsDB->query($sql);
$i = 0;
//$check = array();
$testform = new XoopsThemeForm("", "testform", "setlayers.php");
while (list($name) = $xoopsDB->fetchRow($result)) {
$tray = new XoopsFormElementTray("");
$check = new XoopsFormCheckBox("",$name,"0");
$check->addOption("0",$name);
echo "$name";
$tray->addElement($check);
$testform->addElement($tray);
}
The trouble is I can't figure out how to read them after they are posted in my form because there really is no "handle" to post. "$check" is used over and over to create all the checkboxes, so I can't use it.
Any suggections are greatly appreciated.
Doug P