js常用方法

//清空tbody
  function f_clearTbody(id_tbody) {
   var tbody = document.getElementById(id_tbody);
   for(var i=tbody.childNodes.length-1; i>=0; i--) {
    tbody.removeChild(tbody.childNodes[i]);
   }
  }

 

 

 

//初始化下拉列表内容
  function initBox() {
   var fromBox = document.getElementById("fromBox");
   var toBox = document.getElementById("toBox");
   
   fromBox.length = 0; //先清空   
   <%
   if(kmxxList != null) {
    for(int i=0; i<kmxxList.size(); i++) {
   %>
     var newOption = new Option("<%=kmxxList.get(i).getKmmc() %>", "<%=kmxxList.get(i).getKmdm() %>");
     fromBox.options[fromBox.options.length] = newOption; //添加选项
   <%
    }
   }
   %>
   
   toBox.length = 0; //清空
  }

 

 

 

//画表,逐行增加
        var tr=document.createElement("tr");
        var td=document.createElement("td");
        td.innerHTML=ksgxArr[0][i]; //ksmc
        td.align="center";
        tr.appendChild(td);
        
        td=document.createElement("td");
        td.innerHTML=ksgxArr[1][i]; //klmc
        td.align="center";
        tr.appendChild(td);
        
        td=document.createElement("td");
        td.innerHTML=ksgxArr[2][i]; //kmmc
        td.align="center";
        tr.appendChild(td);

 

        document.getElementById('tbody').appendChild(tr);

 

 

 

 

//从可添加列表中删除该选项
        for(var j=0; j<fromBox.options.length; j++) {
         if(fromBox.options[j].value == ksgxArr[3][i]) {
          fromBox.options.remove(j);
          break;
         }
        }
        

 

//添加到已维护列表的选项中
        var newOption = new Option(ksgxArr[2][i], ksgxArr[3][i]);
        toBox.options[toBox.options.length] = newOption; //添加选项

你可能感兴趣的:(function,null)