JavaScript fill the input type hidden from selected multiple option on jquery fill input type file javascript,fill input type date,fill

I have a input that have type like this:

<input class="emailSend" name="emailSend" type="hidden">

Then I have a multiple select option like this

<div class="controls">
      <select id="email" multiple data-rel="chosen" class="input-xlarge" name="email[]">
          <?php
              foreach ($atasan as $data) {
                  echo "<option value='" . $data['email'] . "'>" . $data['email'] . "</option>";
              }
        ?>

       </select>
   </div>

My problem is, I want to fill that hidden input from the option that selected from multiple select option. So let say, the selected option is 'email1', 'email2', 'email3' then would be affected to hidden type like this 'email1, email2, email3'.

I have try this for 3 hour in jquery and I am stuck. My code is like this.

$("#email").change(function() {

        var elements = $("#email option:selected").length;
        var input = $(".emailSend");

        $(".emailSend").html("");
        $.each($("#email option:selected"), function(/*index, element*/) {

            input.val(input.val() + $(this).html() + ", ");
            if (index < elements - 1) {
               //code to remove last comma
               //any idea ?

            }
        });
    });

So appreciated for the help...

EDIT Here is the fiddle :JSFIDDLE

Answer:1

The cell content selection works successfully for a numeric text box (internally handled as a Kendo NumericTextBox control) but for some reason, it doesn't work with a plain textbox column. Attached ...

The cell content selection works successfully for a numeric text box (internally handled as a Kendo NumericTextBox control) but for some reason, it doesn't work with a plain textbox column. Attached ...

  1. kendo ui grid select row
  2. kendo ui grid select all rows
  3. kendo ui grid select row programmatically
  4. kendo ui grid select row event
  5. kendo ui grid select column
  6. kendo ui grid select all checkbox
  7. kendo ui grid select single row
  8. kendo ui grid select cell programmatically
  9. kendo ui grid select row by index
  10. kendo ui grid select first row by default
  11. kendo ui grid select row on button click
  12. kendo ui grid select row after refresh
  13. kendo ui grid select row angular
  14. kendo ui grid select
  15. kendo ui grid select all
  16. kendo ui grid select event
  17. kendo ui grid select multiple rows
  18. kendo ui grid select row by id
  19. kendo ui grid select first row
  20. kendo ui grid select row checkbox

I want to have two optional parts in my regex - either of them can be found in matching string, and also both of them can at the same time. Both of those optional parts consist of a wildcard (I wrote ...

I want to have two optional parts in my regex - either of them can be found in matching string, and also both of them can at the same time. Both of those optional parts consist of a wildcard (I wrote ...

In the parent html page , when I click a link fancybox dialog opens up and I load a laravel php view page in that fancybox. When I press 'login with twitter' button in fancybox dialog, then I want ...

In the parent html page , when I click a link fancybox dialog opens up and I load a laravel php view page in that fancybox. When I press 'login with twitter' button in fancybox dialog, then I want ...

In java, I have this URL as a string: window.location.href = "http://localhost:8080/bladdey/shop/c6c8262a-bfd0-4ea3-aa6e-d466a28f875/hired-3"; I want to create a javascript regular expression to ...

In java, I have this URL as a string: window.location.href = "http://localhost:8080/bladdey/shop/c6c8262a-bfd0-4ea3-aa6e-d466a28f875/hired-3"; I want to create a javascript regular expression to ...

  1. javascript string pull
  2. js retrieve string
  3. javascript pull query string
  4. javascript pull out string
  5. javascript string retrieve
  6. javascript pull number from string
  7. javascript pull date from string
  8. javascript pull number out of string