Solution 1 :

Sorry!! Once again:
Yes, code works at all.

$('#selectkk').load('JSON/kk_select_box.php?' + $.param({
          kk: encodeURIComponent(''),
         plz: encodeURIComponent(''),
         ort: encodeURIComponent(''),        
                // callback function after selectbox has load 
                    var i, filter,
                    $input = $('#ort_kk'),          
                    $options =$('#select_kk').find('option')                    
                            filter = $input.val()
                                var option_text=$(this).text();
                                var pos =;
                                if( pos == -1 ){ 
                                    $(this).remove(); }



But nevertheless, this won’t work:

    if (pos == -1) {
    } else {

Problem :

I would like to show and hide select box options depending on the value of an input field. Strangely enough, this only works with $('thisOption'). Remove () but NOT with:

// or:
$('thisOption').css('visibility', 'hidden')
$('#Selectkk').Load('JSON / kk_select_box.php')
// callback after select box is ready
function() {
  var i, filter,
    $ input = $('# ort_kk'),
    $ options = $('# select_kk').find('option')
  $ Input.keyup(function() {
    filter = $ input.val()
    $ Options.each(function() {
      var option_text = $(this).text();
      var pos =;
      if (pos == -1) {
<script src=""></script>
<div class='input-group'>
  <input name='ort_kk' id='ort_kk' value=''>
<div id='selectkk'> </div>

I don’t want to remove the options. If the input field is corrected, all options for filtering must still be there. So roughly:

if (pos == -1) {
} else {

I hope I was able to describe the problem clearly and hope for your help.
Thank you very much


Comment posted by Rory McCrossan

Does this code work at all? I ask as there are several syntax issues in the question. I’m wondering if these are just mistakes made when creating the question, or they actually exist in your code. Check the console for errors

Comment posted by TeeWee

Hi there, I did it with copy and paste and various spaces were added.