21
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/4 5:51

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


so i have do this :
$element_tray = new XoopsFormElementTray('Options');
$reqoption "select title from ".$xoopsDB->prefix("ann_options")." where pid=$fam_annonce order by title";
$result5 $xoopsDB->query($reqoption);
while (
$result_array $xoopsDB->fetchArray($result5)) 

 
$option "option".$xm;
 
$ener = new XoopsFormCheckBox ($result_array['title'], $option);
 
$ener->addOption(); 
 
$element_tray->addElement($ener);
 unset(
$ener);
 
$xm++;
}
$form->addElement($element_tray);
$form->display();

And it works...
this is not very beautiful but it gives the good result

22
Mithrandir
Re: How to use XoopsFormCheckBox

what's wrong with having checkbox as an array?
Oh wait... I can see at least one problem.

But do remember two things:
1) Initiate $xm ($xm = 0 somewhere above the loop)
2) Send $xm as a hidden variable, so you can have a for-loop on the receiving page

23
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/6 18:36

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


yes.. a good idea for the $xm variable

This code is good now :
$option1 = new XoopsFormElementTray(_CLA_OPTION);
    
$result5 $xoopsDB->query("select title from ".$xoopsDB->prefix("ann_options")." where pid=$fam_annonce order by title");
          
$compte $xoopsDB->query("select  COUNT(*)  FROM ".$xoopsDB->prefix("ann_options")." where pid = $fam_annonce);
          list(
$nbre) = $xoopsDB->fetchRow($compte);
          if (
$nbre >0
          {
              
$xm=1;
        while (
$result_array $xoopsDB->fetchArray($result5)) 
        { 
            
$opt "option".$xm;
            
$ener = new XoopsFormCheckBox (''$opt );
            
$ener->addOption($result_array['title']); 
            
$option1->addElement($ener);
            unset(
$ener);
            
$xm++;
        }
        
$form->addElement($option1);
    }


Login

Who's Online

164 user(s) are online (115 user(s) are browsing Support Forums)


Members: 0


Guests: 164


more...

Donat-O-Meter

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

Latest GitHub Commits