www.webdeveloper.com
Results 1 to 7 of 7

Thread: Need to Remove Table

  1. #1
    Join Date
    Jan 2010
    Posts
    47

    Need to Remove Table

    <table id=table2>
    <tr> <td>....</td> </tr>
    .....
    .....
    </table>

    JS:-

    document.all.table2.removeNode(true); Which is working in IE not in Chrome.

    So I tried these

    document.getElementById('table2').removeChild(table2.childNode[0]);

    AND

    document.getElementById('table2').removeChild(table2.firstChild);

    but no use. Could any one suggest me how to make it work?

    Thanks

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    var tab2 = document.getElementById('table2');
    tab2.parentNode.removeChild(tab2);
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Jan 2010
    Posts
    47
    Thanks Fang, I am getting JS Error saying

    "tab2.parentNode is null or not an object".

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Give the full code you are using.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Jan 2010
    Posts
    47
    I am creating Table dynamically. The 'checkBoxId' used in creation of table is equal to the "devicesSubmittedForUpdate[d].index" used in getElementById

    Code:
    var responseSuccessDev = function(resobj){
    
    	var violsRetd = resobj.responseXML.getElementsByTagName("viol");
    	var msgRetd = resobj.responseXML.getElementsByTagName("message");
    	
    	if(msgRetd.length>0) { 
    	
    		if(msgRetd[0].firstChild.nodeValue == 'OK'){
    		
    			var checkBoxId = resobj.argument.index;	
    			var tableHdr1 = 
    			    '<table id=tbl' + checkBoxId + ' class="vtable" summary="This Table displays the following..."  >'
    					+'<colgroup> <col class="centered" style="width: 3%" />'
    						+'<col class="centered" style="width: 6%" />'						
    					+'</colgroup>'
    				    +'<thead>'
    				    	+'<tr class="no_scroll">'
    							+'<th scope="col"><input type="checkbox" id=chk'+checkBoxId+'_0 onClick="javascript:toggleViolCheckboxes('+checkBoxId+','+violsRetd.length+');" name="viol"></th>'
    							+'<th scope="col">Id.</th>'
    						+'</tr>'
    					+'</thead>'
    					+'<tbody>';
    			var rowData = [ ];
    			rowData[0] = tableHdr1;
    			resobj.argument.data.violCount = violsRetd.length;
    			
    			for(var i=0; i<violsRetd.length; i++) {
    				var violId = violsRetd[i].getElementsByTagName("violId")[0].firstChild.nodeValue;
    				var violationLogK = violsRetd[i].getElementsByTagName("violationLogK")[0].firstChild.nodeValue;				
    				var detailViolationLink = '<a href="javascript:getDetailViolation(\'/ehpasWeb/detailViolation.do\',\'detailViolation\',\''+violId+'\');">';
    				
    				rowData[rowData.length] = 
    					// displaying violation row in display results page
    					'<tr>'
    						+'<td class="vtd"><input type=hidden id=hidChk'+checkBoxId+'_'+(i+1) + ' value='+ violationLogK + ' /><input title='+(i+1)+' type="checkbox" id=chk'+checkBoxId+'_'+(i+1)+' onClick="javascript:updateViolSelCounter(\''+checkBoxId+'\','+(i+1)+');"  name="viol" value="'+violId+'"></td>'
    						+'<td class="vtd">' +  detailViolationLink + violationLogK+'</a></td>';
      				    '</tr>';
      				 
    			} 
    			tableidCounter++;
    			rowData[rowData.length] = '</tbody></table>';
    			
    		}
     };

    Code:
    evalTbl = "document.getElementById('tbl"+ devicesSubmittedForUpdate[d].index +"')";
    			evalTbl.parentNode.removeChild(evalTbl);

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    evalTbl = document.getElementById('tbl'+ devicesSubmittedForUpdate[d].index);
    			evalTbl.parentNode.removeChild(evalTbl);
    At least 98% of internet users' DNA is identical to that of chimpanzees

  7. #7
    Join Date
    Jan 2010
    Posts
    47
    Thanks a lot Fang, Its Works fine.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles