多个checkbox实现radio功能,选中取消

  <div class="" style="margin-bottom:0px;position:relative;margin-left:8px;">
                <div id="checkDiv1" style="display: inline-block; height: 30px; line-height: 30px; vertical-align: central;" οnclick="check(this)">
                    <input type="checkbox" checked="checked" style="width:14px;height:14px;top:3px;position:relative;" id="HDCode" /><label style="margin-left:3px;">1单号</label>
                </div>
                <div id="checkDiv2" style="display:inline-block;margin-left:10px;" οnclick="check(this)">
                    <input type="checkbox" style="width: 14px; height: 14px; top: 3px; position: relative;" id="PCCode" /><label style="margin-left:3px;">2单号</label>
                </div>
                <div id="checkDiv3" style="display:inline-block;margin-left:10px;" οnclick="check(this)">
                    <input type="checkbox" style="width: 14px; height: 14px; top: 3px; position: relative;" id="NoJXS" /><label style="margin-left:3px;">3单号</label>
                </div>
            </div>

  <script>

var iptValue = document.getElementById("workCode");//input输入框

//复选框
        var checkbox1 = document.getElementById("HDCode");
        var checkbox2 = document.getElementById("PCCode");
        var checkbox3 = document.getElementById("NoJXS");

  //复选框选中取消
        function check(obj) {
            if (obj.id == "checkDiv1" && checkbox1.checked == true) {
                pocCode.setAttribute("placeholder", '合单单号')
                checkbox2.checked = false;
                checkbox3.checked = false;
                iptValue.value = "";
                iptValue.focus();
              
            }
            else if (obj.id == "checkDiv2" && checkbox2.checked == true) {
                pocCode.setAttribute("placeholder", '波茨号')
                checkbox1.checked = false;
                checkbox3.checked = false;
                iptValue.value = "";
                iptValue.focus();
               
            } else if (obj.id == "checkDiv3" && checkbox3.checked == true) {
                pocCode.setAttribute("placeholder", '单号')
                checkbox1.checked = false;
                checkbox2.checked = false;
                iptValue.value = "";
                iptValue.focus();
              
            }
        }

 

</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值