如何用JS删除checkbox选中的记录

如何用JS删除checkbox选中的记录,第1张

function selectDelete() {

var documentStrIds=""

var chkUserInfos=document.getElementsByName("chkUserInfos")

for(var i=0i<chkUserInfos.lengthi++){

if(documentIds[i].checked){

documentStrIds+=chkUserInfos[i].value+""

flag=true//表示复选框有被选中的

}

}

if(flag){

window.location.href="......?documentStrIds="+documentStrIds //提交后台 别忘了传参

}

}

后台 读取documentStrIds

if(documentStrIds!=null &&!"".equals(documentStrIds.trim())){

String[] ids=documentStrIds.split("")

if(ids.length>0){

boolean flag=false

for(String idStr : ids){

//循环删除

}

}

}

 <!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <select>

        <option value="">请选择</option>

        <option value="1">1</option>

        <option value="2">2</option>

    </select>

    <button>clear</button>

</body>

<script>

    document.querySelector("button").onclick = () => {

        document.querySelector("select").value=""

    }

</script>

</html>

 请采纳


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/6777311.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-28
下一篇 2023-03-28

发表评论

登录后才能评论

评论列表(0条)

保存