ciao io ho questa funzione(ti do anche quella x eliminare la riga):
dove la prima riga e i pulsanti sono:codice:<script type="text/javascript"> var cntRows=1; function AddRow() { cntRows++ var cell=cntRows var newcell="<input type=\"text\" name=\"riga"+"\" size=\"7\" value=\""+cell+"\">" var newcell2="<input type=\"text\" name=\"art"+"\" size=\"20\">" var newcell3="<input type=\"text\" name=\"qnt"+"\" size=\"20\">" var newcell4="<input type=\"text\" name=\"prezzo"+"\" size=\"20\">" var newcell5="<input type=\"button\" name=\"B2"+"\" size=\"20\" value=\"Inserisci Riga\" onclick=\"AddRow()\">" var newcell6="<input type=\"button\" name=\"B3"+"\" size=\"20\" value=\"Elimina Riga\" onclick=\"DelRow()\">" tDettaglio.insertRow() tDettaglio.rows(tDettaglio.rows.length-1).insertCell() tDettaglio.cells(tDettaglio.cells.length-1).innerHTML=newcell tDettaglio.rows(tDettaglio.rows.length-1).insertCell() tDettaglio.cells(tDettaglio.cells.length-1).innerHTML=newcell2 tDettaglio.rows(tDettaglio.rows.length-1).insertCell() tDettaglio.cells(tDettaglio.cells.length-1).innerHTML=newcell3 tDettaglio.rows(tDettaglio.rows.length-1).insertCell() tDettaglio.cells(tDettaglio.cells.length-1).innerHTML=newcell4 tDettaglio.rows(tDettaglio.rows.length-1).insertCell() tDettaglio.cells(tDettaglio.cells.length-1).innerHTML=newcell5 tDettaglio.rows(tDettaglio.rows.length-1).insertCell() tDettaglio.cells(tDettaglio.cells.length-1).innerHTML=newcell6 } function DelRow() { var current = window.event.srcElement; while ( (current = current.parentElement) && current.tagName !="TR"); current.parentElement.removeChild(current); }
codice:<td><input type="text" name="riga" size="7" value="1" readonly></td> <td><input type="text" name="art" size="20"></td> <td><input type="text" name="qnt" size="20"></td> <td><input type="text" name="prezzo" size="20"></td> <td><input type="button" name="B2" onclick="AddRow()" value="Inserisci Riga"></td> <td><input type="button" name="B3" onclick="DelRow()" value="Elimina Riga"></td>

Rispondi quotando