怎么在jqgrid中设置checkbox多选,怎么获取多选的值

怎么在jqgrid中设置checkbox多选,怎么获取多选的值,第1张

Action里面:

private PromotionManageTo promotionManageTo;

private List<PromotionManageTo> productClass;

get…

set…

SqlMaps里面:

<select resultClass="promotionManagePromotionManageTo">

……

</select>

JSP里面:

<s:iterator value="productClass" status="productClassLength">

<td>

<input type="checkbox" name="promotionManageToproductId" value="<fs:property value="productId"/>" <c:if test="${fn:containsIgnoreCase(promotionManageToproductId, productId)}">checked="checked"</c:if> />

</td>

</s:iterator>

获取 checkbox的选中个数可以直接使用如下jquery语法

$("input[type='checkbox']:checked")length;

实例演示如下

创建Html元素

<div class="box">

<span>点击按钮获取选中个数:</span><br>

<div class="content">

<input type="checkbox" name="test" >萝卜

<input type="checkbox" name="test" >青菜

<input type="checkbox" name="test" >小葱

<input type="checkbox" name="test" >豆腐

<input type="checkbox" name="test" >土豆

</div>

<input type="button" class="btn" value="获取被选择个数">

</div>

设置css样式

divbox{width:300px;height:250px;padding:10px 20px;margin:20px;border:4px dashed #ccc;}

divbox>span{color:#999;font-style:italic;}

divcontent{width:250px;height:100px;margin:10px 0;padding:5px 20px;border:2px solid #ff6666;}

input[type='checkbox']{margin:5px 10px;}

input[type='button']{width:120px;height:30px;margin:10px;border:2px solid #ebbcbe;}

编写jquery代码

$(function(){

$("input:button")click(function() {

alert($("input[type='checkbox']:checked")length);

});

})

观察效果

问题并么有解决 , 使用不同的name值 ,并没有实现单选按钮的效果 ,三个按钮仍然能同时选中

const SexRadio=ReactcreateClass({

getInitialState:function(){

return {}

},

render:function(){

return (

<div>

<form name="form1">

<input type="radio" name="radiobutton1" value="radiobutton" checked /> 喜欢

<input type="radio" name="radiobutton2" value="radiobutton" /> 不喜欢

<input type="radio" name="radiobutton3" value="radiobutton"/> 无所谓<br/>

</form>

</div>

);

}

});

ReactDOMrender(<SexRadio/>,documentgetEl

以上就是关于怎么在jqgrid中设置checkbox多选,怎么获取多选的值全部的内容,包括:怎么在jqgrid中设置checkbox多选,怎么获取多选的值、jquery中怎样获得多选框中,被选择的个数、React form表单多选框CheckBox该怎么取值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

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

原文地址:https://54852.com/web/9393627.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存