Adding to a HTML text field by clicking items in a multiple select box

后端 未结 4 458
[愿得一人]
[愿得一人] 2021-01-26 19:31

I\'m wondering if it is possible that when I click on an item in a multiple select box in HTML that it goes into another form box? Basically, when I click on something I want th

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-26 19:51

    You can do this using jquery, simply by checking for a change in the multi select box and then adding the newly changed data to the input field.

    You can also the jsFiddle http://jsfiddle.net/eUDRV/85/

    $("#values").change(function () {
        var selectedItem = $("#values option:selected");
        $("#txtRight").val( $("#txtRight").val() +  selectedItem.text());
    });
    

提交回复
热议问题