js 한 줄 추가, 모든 줄 삭제, 한 줄 삭제

3191 단어 jsQQHTML

 

  
  function rowsAdd(){
	 var Container = document.getElementById("play");
	 var detailNum = Container.rows.length;
 	 //var _table=document.getElementById("takesheetspec");
 	 var _tr=Container.insertRow(-1);
 	 //alert(_tr.rowIndex);
 	 var _id='pd'+detailNum;
 	 for(var i=0;i<8;i++)
 	  {
 	   var _td=_tr.insertCell(i);
 	   _tr.id=_id;	
 	    switch(i)
 	     {
 	      case 0:
 	      	 _td.id="cell"+detailNum;
 	         _td.innerHTML=detailNum+"<a href='#' name='delete' οnclick=tabledel("+detailNum+")>  </a>";
 	         break;
 	      case 1:
 	         _td.innerHTML="<input type='text' size='7'>";  
 	         break;
 	      case 2:
 	         _td.innerHTML="<input type='text' size='7'>";  
 	         break;
 	      case 3:
 	         _td.innerHTML="<input type='text' size='7'>";  
 	         break;
 	      case 4:
 	        _td.innerHTML="<input type='text' size='7'>";  
 	         break;   
 	      case 5:
 	          _td.innerHTML="<input type='text' size='7'>";  
 	         break;
 	      case 6:
 	         _td.innerHTML="<input type='text' size='7'>";  
 	         break; 
 	      case 7:
 	         _td.innerHTML="<input type='text' size='7'>";  
 	         break; 
		 case 8:
		     _td.innerHTML="<input type='text' size='7'>";  
		 break;
 	     }
 	  }  	 
}
function tabledel(row)
{
	var Container = document.getElementById("play");		
		//alert(document.getElementById('index').value);	
		var _tr=document.getElementById("pd"+row);	
		row=_tr.rowIndex;
		Container.deleteRow(row);	
		var LastTrIndex = Container.rows.length;
		//var afterDel=row-1;
		row+=1;
		for(row;row<=LastTrIndex;row++) {
			var _td=document.getElementById("cell"+row);	
			var _tr=document.getElementById("pd"+row);	
			var newRow=_tr.rowIndex;
			_tr.id='pd'+newRow;
			_td.id="cell"+newRow;
			_td.innerHTML=newRow+"<a href='#' name='delete' οnclick=tabledel("+newRow+")>  </a>";
		}
}
function tabAllDel() 
{
var Container = document.getElementById("play");
Container.firstChild.removeNode(true);
//    
var tr=Container.insertRow(-1);
var  cell  =  tr.insertCell(0);   
cell.innerHTML = "&nbsp;";
cell  =  tr.insertCell(1);   
cell.innerHTML = "  ";   
cell  =  tr.insertCell(2);   
cell.innerHTML = "  "; 
cell  =  tr.insertCell(3);   
cell.innerHTML = "  "; 
cell = tr.insertCell(4); 
cell.innerHTML = "QQ"; 
cell = tr.insertCell(5); 
cell.innerHTML = "MSN"; 
cell= tr.insertCell(6); 
cell.innerHTML = "E-mail";    
cell= tr.insertCell(7); 
cell.innerHTML = "  ";       
}
    

 


 
   New Document 
 
  
 신규 줄
  모든 줄 삭제
  
  QQ MSN E-mail

 

좋은 웹페이지 즐겨찾기