I have a medium size menu with a few subcategories and a lot of checkboxes. I work on custom CMS with php, mysql and jquery/javascript.
The menu is in a form with a button "Save" that needs to get all values from checked checkboxes.
On button I use onclick function that leads to my class in which I use those id's and store them in a table.
<input type="submit" value="Save" class="save-butt" onclick="sjx('domain', $( ':checkbox' ).serializeArray()); return false;">
It does not work; i don't get any error but it seems that the value is not sent. Here is my menu code if it helps.
<div class="personal-right-box">
<ul class="doe-list">
<?php
$mainCat = Db::query('SELECT * FROM categories WHERE parent_id = 0 ORDER BY orderby DESC');
foreach ($mainCat as $main) { ?>
<li>
<span><i class="fa fa-caret-down toggle-down"></i><?php echo $main['title_hr']; ?></span>
<ul class="doe-list-sub">
<?php
$subCat = Db::query('SELECT * FROM categories WHERE parent_id = '.$main['id'].' ORDER BY title_hr ASC');
foreach ($subCat as $sub) { ?>
<li>
<input type="checkbox" name="" id="aaeroplanes-b1-b2" value="<?php echo $sub['id']; ?>">
<label for="aaeroplanes-b1-b2"><?php echo $sub['title_hr']; ?></label>
<i class="fa fa-caret-down toggle-down"></i>
<ul class="doe-list-sub">
<?php
$subsubCat = Db::query('SELECT * FROM categories WHERE parent_id = '.$sub['id'].' ORDER BY title_hr ASC');
foreach ($subsubCat as $subsub) { ?>
<li>
<input type="checkbox" name="" id="piston-engine-aeroplanes-b1-2" value="<?php echo $subsub['id']; ?>">
<label for="piston-engine-aeroplanes-b1-2"><?php echo $subsub['title_hr']; ?></label>
<i class="fa fa-caret-down toggle-down"></i>
<ul class="doe-list-sub">
<?php
$subsubsubCat = Db::query('SELECT * FROM categories WHERE parent_id = '.$subsub['id'].' ORDER BY title_hr ASC');
foreach ($subsubsubCat as $subsubsub) { ?>
<li>
<input type="checkbox" name="" id="cessna" value="<?php echo $subsubsub['id']; ?>">
<label for="cessna"><?php echo $subsubsub['title_hr']; ?></label>
<i class="fa fa-caret-down toggle-down"></i>
<ul class="doe-list-sub group">
<?php
$items = Db::query('SELECT * FROM categories WHERE parent_id = '.$subsubsub['id'].' ORDER BY title_hr ASC');
foreach ($items as $item) { ?>
<li class="col-1-3">
<input type="checkbox" name="" id="" value="<?php echo $item['id']; ?>">
<label for=""><?php echo $item['title_hr']; ?></label>
</li>
<?php } ?>
</ul>
</li>
<?php } ?>
</ul>
</li>
<?php } ?>
</ul>
</li>
<?php } ?>
</ul>
</li>
<?php } ?>
</ul><!-- end of .doe-list -->
<span class="save-button-form">
<input type="submit" value="Save" class="save-butt" onclick="sjx('domain', $( ':checkbox' ).serializeArray()); return false;">
</span>
</div>
Thank you for your help.
Aucun commentaire:
Enregistrer un commentaire