JSFiddle - React, Tailwind, and code Playground

by bastozz

HTML

<label class="folmlabel">Тип объявления :</label> <select
                        name="ad_type" id="tepy_onsel" >
                        <option value="">-- Тип объявления --</option>
                           <option value="1">Продам</option>
                            <option value="2">Сдам</option>
                            <option value="3">Куплю</option>
                            <option value="4">Сниму</option>
                           
  <option value="c">c</option>



                    </select>
          <label class="folmlabel">Вид объекта:</label>
                    <div>
                    <input type="radio" name="houset_type" value="1/>Дом</input>
                    <input type="radio" name="houset_type" value="2" id="123"/>Дача

                    <input type="radio" name="houset_type" value="5" id="abc"/>Земля

JavaScript

jQuery.fn.filterOn = function(radio, values) {
    return this.each(function() {
        var select = this;
        var options = [];
        $(select).find('option').each(function() {
            options.push({value: $(this).val(), text: $(this).text()});
        });
        $(select).data('options', options);
        $(radio).click(function() {
            var options = $(select).empty().data('options');
            var haystack = values[$(this).attr('id')];
            $.each(options, function(i) {
                var option = options[i];
                if($.inArray(option.value, haystack) !== -1) {
                    $(select).append(
                    $('<option>').text(option.text).val(option.value)
                    );
                }
            });
        });            
    });
};

$(function() {
    $('#tepy_onsel').filterOn('input:radio[name=houset_type]', {
        'abc': ['1','3'],
        '123': ['1','2','3','4']        
    });
});