checkbox传值请教(JSP)
<body>
<form action="actions/Role_updataRole" method="post">
<table class="suggestTable">
<tr>
<td align="center">角色名:</td>
<td><s:property value="#request.role.name" /></td>
</tr>
<tr>
<td scope="col" align="center">菜单名称</td>
<td scope="col" align="center">查询权</td>
<td scope="col" align="center">修改权</td>
<td scope="col" align="center">删除权</td>
<td scope="col" align="center">新增权</td>
<td scope="col" align="center">打印权</td>
<td scope="col" align="center">导出权</td>
</tr>
<tr>
<td scope="col" align="center"><input type="checkbox" name="yhqx.caidan.id" value="2" />用户管理</td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.cxq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.xgq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.scq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.zjq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.dyq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.dcq" value="1" /></td>
</tr>
<tr>
<td scope="col" align="center"><input type="checkbox" name="yhqx.caidan.id" value="3" />角色管理</td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.cxq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.xgq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.scq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.zjq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.dyq" value="1" /></td>
<td scope="col" align="center"><input type="checkbox" name="yhqx.dcq" value="1" /></td>
</tr>
<tr>
</tr>
</table>
<input type="hidden" name="role.id" value="<s:property value="yhqx.role.id" />"/>
<input type="submit" align="center" name="Submit" value="确定" />
</form>
</body>
代码如上,我想把value的值传给name对应的列(数据库里的列)
请问怎么弄(本人学JAVA没多久,以前编程比较差的)
------解决方案--------------------
前台用js获取checkBox的值 可以把它们用字符串拼接起来 用个隐藏域传到后台action,再在action里取出字符串,在进行对数据库的操作
[解决办法]
也可以 直接在后台取chenckBox值String[ ] pks = request.getParameterValues("pk"); 在通过循环插入数据库
[解决办法]
你的表结构是什么样的啊?
[解决办法]
一步一步调试,看看传过来的值就行了
[解决办法]
String cxq = request.getParameter("yhqx.cxq");String xgq = request.getParameter("yhqx.xgq");……
[解决办法]