database - Select some checkbox in a select with a SQL request -


i new here , happy here :). sorry bad english.

my question simple.

<select id="test1" onchange="" multiple="multiple"> <?php      foreach (getcategories() $key => $value) {         echo    "<option id=".$value["id"].">".$value["name"].'</option>';     }    ?> </select> 

this code create category list. use bootstrap multiselect, select made of checkboxes.

i want check category if product in category.

<select id="test2" onchange="" multiple="multiple"> <?php      foreach (getcategoriesparentes(10) $key => $value) {         echo    "<option id=".$value["id"].">".$value["name"].'</option>';     }    ?> </select> 

this same code create list categories of product id 10. (so, can use function getcategoriesparentes(id) me )

i in first select option, categories parents of products checked. dont know if it's possible in jquery like.

thank help.

you don't need javascript make these checkboxes selected. add if condition in php code , if condition satisfied make,

<option selected="selected">some value</option> 

option "selected" above.

here html example shows how it

https://jsfiddle.net/hydride/j2rsefpc/


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -