How to put values in textbox from listbox in jQuery MVC ASP.NET
I have one Listbox named "List1" and one button says "Append".
I have on textbox named "TextDescription". I want to put the select values from the listbox to textbox on click of append button.So can any开发者_如何学JAVAone tell me how to do this?
You could use the .val()
function. So assuming you have a select with id="myselect"
and a text input with id="mytext"
you could do this:
var values = $('#myselect').val();
if (values != null) {
// concatenate the selected values with , so that we can add them to the textbox
$('#mytext').val(values.join(','));
}
And here's a live demo illustrating it in action.
精彩评论