0

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 anyone tell me how to do this?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

14 Comments

Thanks Darin Dimitrov, but i want to add the value in textbox not in listbox
@Saloni , oops, sorry, I misread your question. I've updated my answer.
Thanks Darin Dimitrov, When i m using in application then its giving this error "Microsoft JScript runtime error: The value of the property '$' is null or undefined, not a Function object"
@Saloni, the example I provided uses jQuery. Aren't you using this?
yes i m using jquery but instead of using a tag i m using button
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.