spring-mvc - 我如何在多个复选框上调用控制器类中的方法来更新spring mvc中的记录
问题描述
一旦我选择了一个我想更新数据库的复选框,我就有一个带有复选框的数据表,当我选择所有复选框时,所有记录都应该使用常见值(如 1)进行更新;
提前致谢。
解决方案
您可以使用任何客户端语言进行操作。但是,在这里我使用了 jquery。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("input[type=checkbox]").each( function(i, field){
if($("#c"+(i+1)).prop("checked")){
$("#results").append("you have selected :"+field.name );
}
});
});
});
</script>
</head>
<body>
one: <input type="checkbox" name="1" id="c1" value="1" ><br>
two: <input type="checkbox" name="2" id="c2" value="2"><br>
three: <input type="checkbox" name="3" id="c3" value="3"><br>
four: <input type="checkbox" name="4" id="c4" value="4"><br>
<button>click here</button>
<div id="results"></div>
</body>
</html>
在客户端对象创建时使用上述方式。
推荐阅读
- python - Python忽略源.env文件
- javascript - JavaScript如何写一个小数点后2位的数字,它会以十进制显示0?
- java - 为什么 currenuser ID (firebase) 在我的 android 聊天应用程序中随接收者 ID 发生变化,这导致我的 Seen 消息功能出现问题?
- nginx - 呼叫超时(错误 1006) - bigbluebutton
- google-chrome - 不支持组件树
- python - Correct usage of Django's user_permissions and get_user_permissions()?
- javascript - jquery - 选择的文本一直被存储输出重复的文本
- php - 用于获取多个表数据的 Hasmany 关系
- powershell - Powershell 这两个变量有什么区别
- node.js - 从 Package.json 脚本运行 BrowserSync 时出错