• Resolved UserDG

    (@tenkepadu)


    Hi, how can I change the checkboxes into dropdown? And remain the default setting of the checkboxes. What I mean is, all values are already displayed when the page is visited. Here’s the link: http://bit.do/bLNZx

    I have js that will convert the checkbox into dropdown, but the default setting is lost.

    (function($){
    	"use strict"
    
    	$(function(){
    		var $job_types_select = $('<select class="job_types_select"></select>');
    		var $job_types_ul = $('form.job_filters ul.job_types');
    		var $job_type_hidden = $('<input type="hidden" name="filter_job_type[]"/>');
    			$job_types_ul.find('li').each(function(){
    				var $li = $(this);
    				var label_text = $li.find('label').text();
    				var value = $li.find('input:checkbox').val();
    				var $option = $('<option></option>');
    				$option.text(label_text);
    				$option.attr({value: value});
    				$job_types_select.append($option);
    				});
    				$job_types_select.change(function(){
    				var value = $(this).val();
    				$('input:hidden[name="filter_job_type[]"]').val(value);
    					var target = $(this).closest('div.job_listings');
    					target.triggerHandler('update_results', [ 1, false ]);
    				});
    		$job_types_ul.after($job_type_hidden);
    		$job_types_ul.replaceWith($job_types_select);
    	});
    })(jQuery);

    https://wordpress.org/plugins/wp-job-manager/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Checkbox to dropdown’ is closed to new replies.