1
philou
How to use XoopsFormCheckBox
  • 2004/4/2 21:30

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


Hi all,
I have a big problem with a small code.
I want to read a table and with using the XoopsFormCheckBox class generate some checkbox.
here is the code
$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 (_CLA_OPTION,$result_array[],$result_array[]);
              
$ener->addOptionArray($result_array);
                }

When I insert a
echo $result_array['title'];
in the loop I can see that the $result_array is ok.. not empty.
Can someone help me please ????

Thanks a lot

2
Catzwolf
Re: How to use XoopsFormCheckBox
  • 2004/4/2 22:10

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Ok, first what you trying to do? And what error are you getting?

From what I can see is that you are trying to use a $string here? But checkboxes are 0/1 (either its true or its not).

Unless 'title' is numeric here it wont work.


3
Dave_L
Re: How to use XoopsFormCheckBox
  • 2004/4/3 0:20

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Examples:

// Display checkbox, initially checked.
$checked_value 1;
$checkbox1 = new XoopsFormCheckBox('''box1'$checked_value);
$checkbox1->addOption($checked_value_MD_MODNAME_CHECK_ME);
$form->addElement($checkbox1);


// Display checkbox, initially unchecked.
$checked_value 1;
$checkbox2 = new XoopsFormCheckBox('''box2', !$checked_value);
$checkbox2->addOption($checked_value_MD_MODNAME_CHECK_ME);
$form->addElement($checkbox2);


Assuming the form's method is POST:

If box 1 is checked, the submitted form will have $_POST['box1'] = 1. Otherwise $_POST['box1'] will be undefined.

If box 2 is checked, the submitted form will have $_POST['box2'] = 1. Otherwise $_POST['box2'] will be undefined.

4
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 10:35

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


it's ok thanks.. I understand how to use the "standard" XoopsFormCheckBox but I want to replace
....
while(list(
$title) = $xoopsDB->fetchRow($result5))
 { 
  
$option "option".$xm;
  echo 
"<input name='$option' type ='checkbox' value="$title">$title ";
  
$xm++;
 }
by the XoopsFormCheckBox. I don't know how to trnsform this...

5
Mithrandir
Re: How to use XoopsFormCheckBox

$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 (_CLA_OPTION'checkbox[]'1);
    
$ener->addOption($result_array['title']);
}

6
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 11:01

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


when I do this... I have just the first checkbox...
that's my trouble

7
Mithrandir
Re: How to use XoopsFormCheckBox

whoops - you need to have a
$form->addElement($ener);

Inside the loop as well

8
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 13:36

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


oups.....
I have this now :
$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 (_CLA_OPTION'checkbox[]'1);
    
$ener->addOption($result_array['title']);
    
$form->addElement($ener);
}
    
$form->display();


and the result is :
(I have 3 records tata, tbtb, tctc in the database)
3x lignes with "_CLA_OPTION" and a checkbox "tctc"
Strange isn't it ?


9
Mithrandir
Re: How to use XoopsFormCheckBox

All three lines have option tctc?

I am thinking that it would be better with
$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);
    
$ener->addOption(_YES);
    
$form->addElement($ener);
}
    
$form->display();

10
philou
Re: How to use XoopsFormCheckBox
  • 2004/4/3 18:51

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


yes... and I don't understand why
I have 3 lines :

option : [] tctc
option : [] tctc
option : [] tctc

I want just have a 'classic' checkbox list as
I hope it's possible.... with a XoopsFormElementTray and have this :

option : []tata []tbtb []tctc

Login

Who's Online

169 user(s) are online (129 user(s) are browsing Support Forums)


Members: 1


Guests: 168


heyula,

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