fill input from select not working

fill input from select not working

Hi ! 
I want to fill an input type=text from a selected value, there is no js error on the page but my code is not working, input keeps empty

I have tried with name or id  : same result

thank you

  1. <script>jQuery(function ($) {$("select[name='selectGroupIds']").change(function() {
  2.         $("input[name='jform[user_ids]']").eq($(this).index()).val(this.value);
  3.     }).change();
  4. }); </script>

  5. <input type="text" name="jform[user_ids]" id="jform_user_ids" value="" class="inputbox">

  6. <select id="selectGroupIds" name="selectGroupIds" aria-invalid="false">
  7. <option value="">Select group</option>
  8. <option value="79,173,244,82,292,81,119,161,83,1428,231">group 1</option>
  9. <option value="533,126,346,164,108,242,805,291,359">group 2</option>
  10. <option value="286,325,157,288,1234,209,283,150,387,287,260">group 3</option>
  11. </select>