I am working in wordpress.I have fetched data from database and display in a dropdown.
And my code is like this.
<select multiple="multiple" class="tole_int">
<?php
global $wpdb;
$query_interest = "select p.* from wp_posts as p where p.post_type = 'interests' and p.post_name !='' ";
$tolerancetypes = $wpdb->get_results($query_interest,OBJECT);
foreach($tolerancetypes as $key=>$interest)
{
?>
<option value="<?php echo $interest->ID; ?>"><?php echo ucfirst($interest->post_name); ?></option>
<?php
}
?>
</select>
I have written multiple=”multiple” property for selecting multiple values.But I want to add check box along with the values. So what should I have to write?
Try this “Bootstrap Multiselect”
http://davidstutz.github.io/bootstrap-multiselect/
Then you don’t need to write checkbox code manually.
Make sure you are adding the checkbox in
Form
, if you want to use this inmetabox
no need to createForm
So, Change
selectbox
tocheckbox
And when submitting the form you can get the values seprated by comma and save
or if you want to check the output of multiple checkbox values try