js实现选中的checkbox的值

	function getSelectedIds()
	{
		var checkList = document.getElementsByName("selectKeyIds");
			
		if(checkList==null)
		{
			return "";
		}
			
		var strSelectedIds = "";
		
		for(var i=0; i<checkList.length; i++)
		{
			if(checkList[i].checked==true)
			{
				strSelectedIds += checkList[i].value + ",";
			}
		}
			
		if(strSelectedIds.substring(strSelectedIds.length-1, strSelectedIds.length)==",")
		{
			return strSelectedIds.substring(0, strSelectedIds.length - 1);
		}
		else
		{
			return strSelectedIds;
		}
	}

 

你可能感兴趣的:(checkbox)