博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
checkbox获取选中行的值
阅读量:4186 次
发布时间:2019-05-26

本文共 1122 字,大约阅读时间需要 3 分钟。

开发过程中遇到获取checkbox的选中行的某个值,代码如下。checkbox只能选中一个,但是找了很多方法都无效,所以就根据checkbox的长度进行判断了。有好的方法,希望不吝赐教。

 

function getCheckBox(ob){	  var rowid = $(ob).attr("id") //获取当前行的id	   console.log("row.id:"+rowid);	  var len = $("input[name=test]:checked").length; //获取checkbox的选取长度	  console.log("len"+len);	  if(len==1){		  var check = $("input[name=test]:checked");//选中的复选框		   check.each(function(){//			   var row = $(this).parent("td").parent("tr");//获取当前行			    supplierName = row.find("[name='suName']").html();// 行根据选择器获取当前行的某个值			   supplierId = row.find("[name='id']").html();			   console.log("suName:"+supplierName);			   console.log("id:"+supplierId);				var xx = "#"+id;   				$("#mdsProcurementPlanTable tbody "+xx).val(supplierName);		   })		  $("#pageId").data("pageCurrent",1);		   jp.post("${ctx}/mds/mdsPurchaseSupplier/updateSupplier",		    		 {id:id,supplierName:supplierName,supplierId:supplierId},function(data){		    			 if(data.success){		    				 jp.success(data.msg);		    			 }else{		    				 js.error(data.msg);		    			 }		    		 })		   $("#myModal").modal('hide');		  }else{			  alert("只能选择一条");		  }	  	    }

 

转载地址:http://tcfoi.baihongyu.com/

你可能感兴趣的文章
CareerCup Randomly return a node in a binary tree
查看>>
CareerCup Given a sorted array which contains scores. Write a program to find occurrence
查看>>
CareerCup The number of pairs (x, y) of distinct elements with condition x + y <= Threshold
查看>>
Build a key-value data structure which can perform lookup and rangeLookup(key1, key2)
查看>>
整数划分问题---动态规划、递归
查看>>
Balanced Partition
查看>>
Number of 1s
查看>>
CareerCup Find all the conflicting appointments from a given list of n appointments.
查看>>
CareerCup Given an array having positive integers, find a subarray which adds to a given number
查看>>
CareerCup Generate all the possible substrings
查看>>
CareerCup Given an array A[], find (i, j) such that A[i] < A[j] and (j - i) is maximum.
查看>>
Brain Teaser 球变色
查看>>
(2)考试大纲---信息系统项目管理师考试系列
查看>>
(3)教材目录---信息系统项目管理师考试系列
查看>>
商城基础E-R模型图
查看>>
飞翔的小鸟--键盘事件案例
查看>>
一个sql函数group_concat详解
查看>>
根据地址返回坐标位置的百度地图api
查看>>
thinkcmf数据字典
查看>>
gitflow 分支原理
查看>>