du521521521 2018-07-08 03:47
浏览 195
已采纳

从下拉列表中选择多个值

How to select multiple value from drop down list?, when the value is selected it will no longer be available in the drop down menu.

[Form Select]

I want can be able to select multiple email addresses at once by pressing the add button where I want to show with a comma separator, so when we choose an email address through the drop down list it will automatically be displayed in the input field 'To' such as: neymar@gmail.com, ronaldo@gmail.com, messi@gmail.com then the user can also delete the last email in the input by pressing the delete button,

  • 写回答

3条回答 默认 最新

  • doulai8405 2018-07-08 04:30
    关注

    You must concat value of selectBox to previous value and replace it to your inputBox.

         var prv_val,f_val;
            $('#test').change(function() {
              var new_val = $(this).val();
              if(new_val != ""){
                prv_val = $('#target_input').val();
                if(prv_val != ""){
                  f_val = prv_val + "," + new_val;
                }
                else {
                  f_val = new_val;
                }
                $('#target_input').val(f_val);
              }
            });
    #target_input {
         display: block;
          height: 30px;
          margin-top: 20px;
          width : 100%;
        }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <select id='test'>
             <option value=""></option>
              <option value="one@gamil.com">one@gamil.com</option>
              <option value="two@gamil.com">two@gamil.com</option>
              <option value="three@gamil.com">three@gamil.com</option>
            </select>
    
            <input value="" id='target_input'>

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?