Carlos Jhon manlulu Carlos Jhon manlulu - 1 year ago 97
Ajax Question

Show the content of Multiple select

i have this code but does not work i just want to put the content of the multiple combobox into textbox name valueholder and every value should be separated by comma. Thanks in advance, i dont know where to start im new in javascript thx

Example output in the textbox should be.


var ValuesArray = $('#countries').val();
var holder = $('#valueholder').val();
ValuesArray== valueholder;
<input type="text" name="valueholder" id="valueholder">
<select id="countries" class="multiselect" multiple="multiple" name="countries[]">

<option value="4800014145089">4800014145089</option>
<option value="4800131590977">4800131590977</option>


Answer Source

It's easy with jquery:

    // get all the option tags
    var options = $('#countries option'); 

    // map the function for each option 
    var values  = $(options).map(function() { 
        return $(this).val(); 


See the working example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download