dimanche 6 mars 2016

Select some checkbox in a select with a SQL request

I am new here and happy to be here :). Sorry for my bad english.

My question is simple.

<select id="test1" onChange="" multiple="multiple">
<?php

    foreach (getCategories() as $key => $value) {
        echo    "<option id=".$value["id"].">".$value["name"].'</option>';
    }  

?>
</select>

This code create an all category list. I use bootstrap multiselect, so my select is made of checkboxes.

I want to check the category if the product is in the category.

<select id="test2" onChange="" multiple="multiple">
<?php

    foreach (getCategoriesParentes(10) as $key => $value) {
        echo    "<option id=".$value["id"].">".$value["name"].'</option>';
    }  

?>
</select>

This nearly same code create a list with only categories of the product id 10. (So, you can use the function getCategoriesParentes(id) to help me )

I would like that in my first select option, all categories parents of the products are checked. I dont know if it's possible in JQuery but I would like.

Thank you for your help.




Aucun commentaire:

Enregistrer un commentaire