tags:

views:

36

answers:

2

hi i am a php developer and using an multiple select box , i want when we select a multiple option from the select box then value of every select box should be display in text box how can i do this with the help of jquery please help if anybody have solution of this thank's

A: 

Try this

$('#multiSelect').change(function() {
    $('#txtSelect').val($('#multiSelect').val());
   });
skyfoot
A: 

Based off a hint from jMar's blog:

$("#multipleSelect").change(function() {
  $("#textBox").val("");
  $("#multipleSelect option:selected").each(function(i) {
    if (i > 0)
      $("#textBox").val($("#textBox").val() + ", " + $(this).text());
    else
      $("#textBox").val($(this).text());
  });
});

If you don't need the commas/separators, it's actually just:

$("#multipleSelect").change(function() {
  $("#textBox").val($("#multipleSelect option:selected").text());
});

Fiddle with it over at jsfiddle.

sirhc