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 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真