循环下的radio操作
来源:互联网 发布:约瑟夫环算法 数组 编辑:程序博客网 时间:2024/04/30 12:47
举实例说明:
<ul> <c:forEach items="${customer.accountList}" varStatus="status" var="acct"> <c:if test="true"> <li> <lable>短信送达服务:</lable> <label>${acct.dhlAccount}</label> <label> @@1、 <input type="radio" name="ac${status.index}" <c:if test="${acct.isHasArrNot=='0'}"> checked='checked'</c:if> onclick="judge('${acct.dhlAccount}')"/>开通</label> <label> @@1、 <input type="radio" name="ac${status.index}" <c:if test="${acct.isHasArrNot=='1'}"> checked='checked'</c:if> onclick="judge('${acct.dhlAccount}')"/> 未/取消开通</label></span> <input type="hidden" name="arrNot" value="${acct.isHasArrNot}" id="name${acct.dhlAccount}";> <input type="hidden" name="arrNotAccount" value="${acct.dhlAccount}" id="${acct.dhlAccount}";> @@2、 <input type="hidden" value="${status.index}" id="bn${acct.dhlAccount}"></li></c:if> </c:forEach> @@3、 <input type="hidden" name="radioValue" id="radioValue"/> </ul>
javaScript调用:
function judge(canshu){var inputval = $("#name"+canshu).val();if(inputval==null||inputval==""){ message("该账号没有短信送达权限,请开通",3);$("#one").val(canshu);@@2、$("input:radio[name='ac"+$("#bn"+canshu).val()+"']").attr("checked",false);}
@@3、 function valueSubmit(){ var accList = "${customer.accountList}";//后台直接传过来的 body里的el表达式 var stringList = accList.substring(accList.indexOf('[')+1,accList.lastIndexOf(']')); var accountList = stringList.split(","); var raValue=""; for(var i=0;i<accountList.length;i++){ var inputList = document.getElementsByName("ac"+i); if(inputList[0].checked==true){ raValue=raValue+","+0; } else if(inputList[1].checked==true){ raValue=raValue+","+1; }else{ raValue=raValue+","+""; } } var str=raValue.substring(1); $("#radioValue").val(str); document.getElementById('formNotice').submit();}
知识点:1、标记为1部分,foreach出来的radio的name命名规则:radio组与radio组之间的name不能一样,组内两个radio的名字要一样。如果radio名字全部都一样,只 有一个radio起作用。
2、、标记为2的部分,jquery根据名字选择radio:
$("input:radio[name='ac']").attr("checked",false); 表示相应的radio去掉选中。
由于radio名字不一样,可以借用input和js方法中的参数来进行传值,来完成相应radio的选择: 这个很重要
如:<input type="hidden" value="${status.index}" id="bn${acct.dhlAccount}"> 的value
onclick=judge('${acct.dhlAccount}') judge的参数
3.标记为3的部分是将选中的radio放入id为radioValue的input的值中,传给后台接收。
******* 在JSp页面中,body传给javascript传值有两种方式:1.通过input的值传给js 2.通过要调用的js方法的参数
****** 在解决问题时,一种思路解决不了的时候,要在适当的时候跳出来换思路。已解决问题为主。
0 0
- 循环下的radio操作
- jquery下的 radio,checkbox,select操作
- jQuery radio的操作
- js对Radio的操作
- jQuery操作radio的不同
- JQuery对radio的操作
- jquery 对radio的操作
- Js操作input的radio
- input radio 选中的操作
- Jquery 操作 radio ,select 标签的操作
- radio操作
- javascript操作radio的几种方法
- jQuery-对Radio/CheckBox的操作集合
- jQuery-对Radio/CheckBox的操作集合
- JQUERY对RADIO,CHECKBOX,SELECT的操作
- jQuery-对Radio/CheckBox的操作集合
- jQuery-对Radio/CheckBox的操作集合
- MFC关于Radio按钮的操作
- 治愈系--致郁系
- 使用STM32F4XX自带数学库"arm_math.h"
- 第一个自己完成的leetcode( JAVA) Implement Queue using Stacks
- [LeetCode]Longest Palindromic Substring
- c#猜猜看
- 循环下的radio操作
- BAPI_PO_CREATE
- 数据挖掘方向
- TCP协议和UDP协议简单实例
- 怎样将MathType中的公式加入到iBooks Author
- yaml随笔记(一)
- openwrt uci常用命令
- [Unity3D]如何计算某个pixel的depth precision
- 最详细安卓ADT插件安装教程