Post n°3 pubblicato il 30 Novembre 2011 da brunogioielli
<html> <head> <title>Generazione Tabella</title> <b>Magazzino HIP HOP</b> <br><br> <script> //Var globali var tab; function Tabella(rows,cols,container) { var vals= new Array(rows); for (i=0;i<rows;i++) vals[ i ]=new Array(cols); //Campi this.rows=rows; this.cols=cols; this.vals=vals; this.selcol=-1; this.selrow=-1; this.container=container; //Metodi this.disegna=disegna; this.select=select; this.save=save; } function select(row,col) { this.selcol = col; this.selrow = row; this.disegna(); } function save(row,col) { this.vals[row][col]=document.getElementById("inbox").value; this.selcol=-1; this.selrow=-1; this.disegna(); } function disegna() { div=this.container; str="<table border=1>"; for (i=0;i<this.rows;i++) { str+="<tr>"; for (j=0;j<this.cols;j++) { if (this.selcol != j || this.selrow != i) { str+="<td onclick="tab.select(" + i + "," + j + ")">"; str+=this.vals[ i ][j]; } else str+="<td><form><input type=text value=" + this.vals[ i ][j] + " id="inbox"><input type=button value=Salva onclick="tab.save(" + i+"," + j +")"></form>"; str+="</td>"; } } str+="</table>"; div.innerHTML=str; } function creatabella() { tab= new Tabella(60,2,document.getElementById("tablediv")); tab.disegna(); } </script> </head> <body onload="creatabella();"> <div id="tablediv"></div> </body> </html> |
Post n°2 pubblicato il 30 Novembre 2011 da brunogioielli
|
Post n°1 pubblicato il 30 Novembre 2011 da brunogioielli
Generazione Tabella Magazzino HIP HOP |