Saturday, 10 March 2012

How to Access HTML Table Row, Table Cell Using Javascript


function displayResult(Prod_name, weightId, weightValue, ProdId,Show_Amount, Amount, Total_Amt,Qty,WeightFormat,Gm_w)
{
debugger;
var table=document.getElementById("cart");

var TableRows = table.getElementsByTagName('tr');


var row=table.insertRow(1);
row.style.borderdColor = "Black";
var cell1=row.insertCell(0);
var cell2=row.insertCell(1);
var cell3=row.insertCell(2);
var cell4=row.insertCell(3);
var cell5=row.insertCell(4);
var cell6=row.insertCell(5);
var cell7=row.insertCell(6);
var cell8=row.insertCell(7);

cell1.innerHTML=Prod_name;
cell2.innerHTML = ProdId;
cell3.innerHTML = weightValue;

cell4.align = "center";
cell4.innerHTML = weightId.value;

cell5.align = "right";
cell5.innerHTML = Show_Amount;

cell6.innerHTML = Amount;

cell7.align = "right";
cell7.innerHTML = Total_Amt;

cell8.align = "center";
cell8.innerHTML = "<INPUT TYPE=\"Button\" CLASS=\"Button\" id=\"delete\" onClick=\"deleteRow(this,"+Qty+","+weightId.id+","+Gm_w+")\" style=\"background-image: url(images/delete1.png); width: 15px; height:15px; border:none\">";


//,'"+WeightFormat+"'
//alert(ProdId);
    for (var r=0; r<TableRows.length;r++)
    {
      var cels = TableRows[r].getElementsByTagName('td')
      cels[1].style.display='none';
      cels[3].style.display='none';
      cels[5].style.display='none';
     
//      alert(cels[1].innerHTML);
     
    }
// Total Not of Item and Total Amount Calculation//

document.getElementById("LblNOI").innerHTML  = TableRows.length-1;

var WholeAmt = document.getElementById ("LblTotalAmt").innerHTML;
WholeAmt=parseFloat(WholeAmt)+Total_Amt;
document.getElementById ("LblTotalAmt").innerHTML = WholeAmt;

//cell2.style.display='none';

}

No comments:

Post a Comment