bootstarp下实现下拉框可以输入

<div style="padding:5px ;position:relative" class="col-sm-4">
    <span style="position:absolute;top:5px;overflow:hidden;width:95%;height:32px;">
        <!--这个是个多选框,用onchange事件的时候 ,将这个select的id传进去-->
               <select name="trains" onchange="qlcTrainS('hn_select_input')" class="form-control" id="hn_select_input" style="height:30px;outline:0;">
                   <option value="test1">test1</option>
                   <option value="test2">test2</option>
                   <option value="test3">test3</option>
                   <option value="test4">test4</option>
                   <option value="test5">test5</option>
               </select>

    </span>
    <span style="position:absolute;top:7px;left:10px;margin-top:1px;margin-left:1px;width:80%;height:28px;border-radius:5px;">
        <!--这里是input框,定位到select的上面-->
              <input type="text" name="ccdd" id="hn_input_value" class="ccdd" placeholder="可选择也可输入的下拉框" style="width:80%;height:24px;border:0pt;border-radius:5px;outline:0">
    </span>
</div>
<script>
    <!--将select的值赋给input框-->
    function qlcTrainS(selectIdName) {
        var arrValue=document.getElementById(selectIdName).options[document.getElementById(selectIdName).selectedIndex].value;
        console.log(arrValue)
        $("#"+selectIdName+"").parent('span').next('span').children('input.ccdd').val(arrValue)
    }

</script>

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值