The problem of passing parameters before and after ajax


How to select the id of multiple checkboxes, and pass the value to the page for operation
Note : The value is a set of checkboxes, so you cannot use document.getElementById()
/*    *
   to select multiple pieces of data, how to get the id
   **
Get all selected ids
   *When selecting multiple data, get all the selected ids, and return
   the ids *Get all the ids, and use "," to spell them together. When using, use the split() method to split them and put them in Use
   */ 
->  
   function getAllids(){ 
       //to get the checkbox object 
       var checkbox = document.getElementsByName("che"); 
       //alert("checkbox length is: "+checkbox.length); 
       var id = ""; 
       //When selected, get its value and spell it out 
       //It should be noted that the id string spelled out in this way ends with ",", so when using , you should remove the "," first, or you can make a judgment in the if 
       //When it is the last one, do not add "," when spelling 
       for ( var i = 0; i < checkbox.length;  i++) { 
           if(checkbox[i].checked){ 
               id = id + checkbox[i].value+","; 
           } 
       } 
       //alert("id is: "+id); 
       return id; 
   }

================= ===================================================
// Get an array of all checkbox objects 
function GetAllCheckBox() { 
  var div = document.getElementById("Balls"); 
  var inputs = div.getElementsByTagName("input"); 
  //Define an array of checkboxes to return 
  var checkboxes = new Array(); 
  var nIndex = 0; 
  for (var i = 0; i < inputs.length; i++) { 
//Check the checkbox by whether the type is checkbox 
if (inputs[i].type == " checkbox") { 
   checkboxs[nIndex] = inputs[i]; 
   nIndex++;   

  } 
  return checkboxs; 

 
 
 
//全选 
function selAll() { 
  var checkboxs = GetAllCheckBox(); 
  for (var i = 0; i < checkboxs.length; i++) { 
checkboxs[i].checked = true; 
  } 

 
 
 
//全清 
function clearAll() { 
  var checkboxs = GetAllCheckBox(); 
  for (var i = 0; i < checkboxs.length; i++) { 
checkboxs[i].checked = false; 
  } 

 
 
 
//反选 
function reverseAll() { 
  var checkboxs = GetAllCheckBox(); 
  for (var i = 0; i < checkboxs.length; i++) { 
if (checkboxs[i].checked == true) { 
   checkboxs[i].checked = false; 

else { 
   checkboxs[i].checked = true; 

  } 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326142199&siteId=291194637