Forums › Forums › Search & Filter Pro › Is it possible to have combo box with check box for a SELECT search field?
- This topic has 6 replies, 4 voices, and was last updated 8 years, 4 months ago by Trevor.
-
Anonymous(Private) August 14, 2015 at 9:00 am #23219
Hi,
I am curious to know if we already have the feature of combo box(dropdown) with check box for a search field?
something like
https://imgur.com/m2TqmfMThanks
Anonymous(Private) August 18, 2015 at 5:02 pm #23394DONE!!!
// used some java script jquery.min.js and jquery.multiple.select.js and multiple-select.css
<link rel=”stylesheet” href=”/wordpress/wp-content/themes/sydney/login/multiple-select.css” />
//After $returnvar .= “</select>”;
//Add
$returnvar .= ‘<script src=”/wordpress/wp-content/themes/sydney/js/jquery.min.js”></script>
<script src=”/wordpress/wp-content/themes/sydney/js/jquery.multiple.select.js”></script>
<script>$(function() {
$(“#’.str_replace(‘/’, ”, $name).'”).change(function() {
console.log($(this).val());
}).multipleSelect({
width: “100%”
});
});
</script>’;Anonymous(Private) August 21, 2015 at 8:58 am #23544For Full code..its here..
Add this new function in class-search-filter-generate-input.php filepublic function generate_multiselectcheckbox($dropdata, $name, $defaults, $elem_attr = "",$id="",$all_items_label=null) { $returnvar = ""; // if($additionalFeature==false){ // $returnvar .= '<div style="display:none;" id="div_' . str_replace('/', '', $name) . '">'; // } // else{ // $returnvar .= '<div style="" id="div_' . str_replace('/', '', $name) . '">'; // } $returnvar .= '<select multiple="multiple" class="postform" name="'.$name.'[]"'.$elem_attr.'id="'.str_replace('/', "", $name).'" slug="'.$all_items_label.'">'; if(isset($all_items_label)) { if($all_items_label=="") {//check to see if all items has been registered in field then use this label $returnvar .= '<option selected="selected" class="level-0" value="'.$name.'">'.esc_html($all_items_label).'</option>'; } } foreach($dropdata as $dropdown) { $selected = ""; if(isset($defaults)) { if(is_array($defaults)) //there should never be more than 1 default in a select, if there are then don't set any, user is obviously searching multiple values, in the case of a select this must be "all" { foreach($defaults as $defaultid) { if($defaultid==$dropdown->term_id) { $selected = ' selected="selected"'; } } } } $returnvar .= '<option class="level-0" value="'.esc_attr($dropdown->term_id).'"'.$selected.'>'.esc_html($dropdown->cat_name).'</option>'; } $returnvar .= "</select>"; $returnvar .= '<script src="/wordpress/wp-content/themes/sydney/js/jquery.min.js"></script> <script src="/wordpress/wp-content/themes/sydney/js/jquery.multiple.select.js"></script> <script> $(function() { $("#'.str_replace('/', "", $name).'").change(function() { console.log($(this).val()); }).multipleSelect({ width: "100%" }); }); </script>'; return $returnvar; }
choose from the UI which choice_type u want. for example. I choose multi select so Call this function into
if ($values['choice_input_type'] == "multiselect")
by referring$returnvar .= $this->create_input->generate_multiselectcheckbox($countrychildren, $field_name, $defaults, $elem_attr, str_replace('/', '', $field_name), false);
Don’t forget to add the above javascript files and css file.
Keep calm and enjoy coding.. ๐
CheerssssRoss Moderator(Private) August 23, 2015 at 11:30 am #23580Many thanks, will consider integrating this as a feature ๐
-
AuthorPosts