1
2headedpuppy
How to create Select All checkbox w XoopsForm Classes, multiple checkbox elements w multiple options

I am not sure how to do this using XoopsForm classes.

- I have a form (see pic) with two checkbox elements: Fruit Selection and Ripeness.
- Each checkbox element has multiple options (red/blue/medium ..etc.)
- I was able to create a checkbox to select all only for the entire form using xoopsCheckAll but with the checkbox placed outside of the form (prefer having it inline). I tried using xoopsCheckAllElements and xoopsCheckGroup but could not get it to work.

Does anyone have a simple solution how to turn the "Select All" checkboxes below into functioning "Select All" checkboxes using XoopsForm classes. I would like to be able to select all just for "Fruit Color" or just for "Ripeness".

Thanks !!!!!!!!!!!!!!!!!

Resized Image


sample code :

$form = new XoopsThemeForm('Fruit Selection''fruitform''fruit.php''post'true);

$checkbox_color = new XoopsFormCheckBox('Fruit Color''checkbox_color'none);
$checkbox_color->addOption('all','Select All');
$checkbox_color->addOption('red'"Red");
$checkbox_color->addOption('green'"Green");
$checkbox_color->addOption('yellow'"Yellow");
$form->addElement($checkbox_color);

$checkbox_ripeness = new XoopsFormCheckBox('Ripeness''checkbox_ripeness'none);
$checkbox_ripeness->addOption('all'"Select All");
$checkbox_ripeness->addOption('notatall'"Not at all Ripe");
$checkbox_ripeness->addOption('slightly'"Slightly Ripe");
$checkbox_ripeness->addOption('medium'"Medium Ripe");
$checkbox_ripeness->addOption('well'"Well Ripe");
$form->addElement($checkbox_ripeness);

$button = new XoopsFormElementTray('' ,'submitb');
$button->addElement(new XoopsFormButton('''post_fruit_id'"Click Here : Submit Fruit Preference"'submit'));
$form->addElement($button);

$form->display();

2
2headedpuppy
Re: How to create Select All checkbox w XoopsForm Classes, multiple checkbox elements w multiple opt

Figured it out. xoopsCheckGroup will do the trick.

xoopsCheckGroup (form,switchId,groupName)


For the above example, to select all fruit colors you could add a checkbox like below:
<input  name="checkallcolor" id="checkallcolor" onclick="xoopsCheckGroup('fruitform', 'checkallcolor', 'checkbox_color[]');" type="checkbox" value="Check All" />

Login

Username:
Password:

Lost Password? Register now!

Who's Online

57 user(s) are online (35 user(s) are browsing Support Forums)


Members: 0


Guests: 57


more...

Donat-O-Meter

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

Latest GitHub Commits