fill input from multiple select
Hi !
I am trying to fill an input type text from a select multiple, but I can get only value from one selected
- <select multiple="" id="selectGroupIds" name="selectGroupIds" aria-invalid="false">
- <option value="">None</option>
- <option selected="" value="1,2,3">Group 1</option>
- <option value="4,5,6">Group 2</option>
- <option value="10,20">Group 3</option>
- </select>
- <input type="text" name="jform[user_ids]" id="jform_user_ids" value="" class="inputbox" aria-invalid="false">
- <script type="text/javascript">jQuery(function ($) {$("select[name='selectGroupIds']").change(function() {
- var $value = this.value;
- var $input = $("#jform_user_ids");
- $input.val($value);
- }).change();
- });
- </script>
if I select Group 1 and Group 2
the value of input type text should be : 1,2,3,4,5,6 but with an additional comma after each group !
otherwise it will be wrong = 1,2,34,5,6
thanks for helping