1
phillipd
New explanation of problem
  • 2004/11/10 5:12

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


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

Login

Who's Online

163 user(s) are online (78 user(s) are browsing Support Forums)


Members: 0


Guests: 163


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits