html - Holding data in contenteditable tables -
if have simple html table, enabling contenteditable
on table data. possible have formula across table (for example: cell 1 column 1 + cell 2 column 1 = cell 3 column 1) , contenteditable
change variables in formula , updata totals?
i playing little bit contenteditable
:
below simple function can use desired results. , here updated fiddle http://jsfiddle.net/nmhms/441/
plus can add infinite number of columns , rows , dynamically put total in last row
function updatetotal(){ var totalcols=$("#table tr").eq(0).find("td").length-1; var toalrows=$("#table tr").length-1; var cellvalue=0; for(var col=0;col<=totalcols; col++){ for(var row=0;row<=toalrows; row++){ if(row!=toalrows) cellvalue+= parseint($("#table tr").eq(row).find("td").eq(col).text()); if(row==toalrows){ $("#table tr").eq(row).find("td").eq(col).text(cellvalue); cellvalue=0; // reset cell value } } } }
Comments
Post a Comment