11
Mithrandir
Re: How to use XoopsFormCheckBox

$form = new XoopsThemeForm('formname' etc.);

$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)) 
{
    
$ener = new XoopsFormCheckBox ($result_array['title'], 'checkbox[]'1);//or 0 if unchecked as default
    
$ener->addOption(1_YES);
    
$element_tray->addElement($ener);
}
$form->addElement($element_tray);
$form->display();


How's that working?

12
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 19:31

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


It doesn't work...
Just the field 'option' appears as a simple label

13
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 19:46

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


the better...

$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)) 

 echo 
$result_array['title']." -- ";
 
$ener = new XoopsFormCheckBox ($result_array['title'], 'checkbox[]');
 
$ener->addOption(1_YES); 
 
$element_tray->addElement($ener);
}
$form->addElement($element_tray);
$form->display();


gives a line with 3 checkbox <= ok !
but the text isn't ok.
I obtain the following result :
Options tctc [] Oui tctc [] Oui tctc [] Oui

So I check with the
echo $result_array['title']." -- ";
and I have the good list
tata -- tbtb -- tctc

14
Mithrandir
Re: How to use XoopsFormCheckBox

what about the echo statement? Is that displaying the correct titles?

15
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 19:50

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


yes... I have edit the previous post to explain this.

I have the good field content with the echo

16
Mithrandir
Re: How to use XoopsFormCheckBox

Damn... doublepost

17
Mithrandir
Re: How to use XoopsFormCheckBox

God, I am stupid.

The darn element has the same name... $ener.

Try a
unset($ener)
after the $element_tray->addElement

18
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 20:09

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


yep it's ok.....

I am very very stupid !!!
thanks for your support

19
Mithrandir
Re: How to use XoopsFormCheckBox

Nah - I should have picked that one up.

So it's working for you now?

20
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/4 5:40

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


the principle is ok. I have just to add an increment to build a different name for the each checkbox .

The code :
$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)) 

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

The source result :
<td class='head'>Options</td>
<
td class='even'>
tata&nbsp;<input type='checkbox' name='checkbox[]' value='' />
&
nbsp;tbtb&nbsp;<input type='checkbox' name='checkbox[]' value='' />
&
nbsp;tctc&nbsp;<input type='checkbox' name='checkbox[]' value='' />

when I use your
$ener->addOption(1_YES);

I have for example
tata [x]oui
(oui is the tranlation of _YES in my language)

Login

Who's Online

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


Members: 0


Guests: 172


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