<!--
var num=2;
function accoda(){
if(document.createElement && document.getElementById && document.getElementsByTagName) {
// crea elementi
var oTr=document.createElement("TR");
var oTd1=document.createElement("TD");
var oTd2=document.createElement("TD");
var oField=document.createElement("INPUT");
var oText=document.createTextNode("email "+num);
// setta attributi
oField.setAttribute("type","text");
oField.setAttribute("name","email"+num);
oField.setAttribute("size","55");
// appendi al relativo padre
oTd1.appendChild(oField);
oTd2.appendChild(oText);
oTr.appendChild(oTd1);
oTr.appendChild(oTd2);
document.getElementById('tabella').getElementsByTa gName('TBODY')[0].appendChild(oTr);
// incrementa variabile globale
num++
}
}
function rimuovi(){
if(document.removeChild && document.getElementById && document.getElementsByTagName) {
// se non e' la prima riga
if(num>2){
// riferimento al tbody
var tb=document.getElementById('tabella').getElementsB yTagName('TBODY')[0];
// riferimento all' ultimo TR
var lastTr=tb.getElementsByTagName('TR')[(tb.getElementsByTagName('TR').length)-1]
// rimuovi
tb.removeChild(lastTr);
// decrementa variabile globale
num--
}
}
}
//-->
</script>
[/code]
--------------------
<input type="button" value="aggiungi" onclick="accoda()"> <input type="button" value="rimuovi" onclick="rimuovi()">
<table border="0" id="tabella">
<tbody>
<tr>
<td><input type="text" size="70" name="email1" class="testo" /></td><td>email 1</td>
</tr>
</tbody>
</table>
Purtroppo non riesco a passare il valore della variabile "num" tramite campo hidden nel form in quanto la vede sempre con il valore impostato all'inizio...
Chi sà darmi delle indicazioni??
Grazie!!