daniel-pyro
Bovino maduro
- Desde
- 24 Sep 2007
- Mensajes
- 499
- Tema Autor
- #1
que tal bakunos con la siguiente cuestion:
tengo el siguiente codigo
asi pues en el codigo envio las variables con el metodo post como meta1 meta2 meta 3 etc...
lo que necesito es saber cuantas variables se crean en total para esto intente enviar la variable numero que se crea en el js
intente guardarla en un campo oculto dentro del formulario pero no lo envia alguien me podria ayudar
tengo el siguiente codigo
Código:
<script language="javascript">var numero = 1;
function addNewRow()
{
var TABLE = document.getElementById("tabla");
var TROW = document.getElementById("celda");
var content = TROW.getElementsByTagName("td");
var newRow = TABLE.insertRow(-1);
newRow.className = TROW.attributes['class'].value;
var newCell = newRow.insertCell(newRow.cells.length)
numero++;
newCell.innerHTML = '<div align="center">'+(numero)+'</div>'
newCell = newRow.insertCell(newRow.cells.length)
newCell.innerHTML = '<textarea name="metas'+(numero)+'" cols="45" rows="3" id="metas" style=" overflow:hidden"></textarea>'
newCell = newRow.insertCell(newRow.cells.length)
newCell.innerHTML = '<textarea name="compromisos'+(numero)+'" id="compromisos" style=" overflow:hidden" cols="45" rows="3"></textarea>'
newCell = newRow.insertCell(newRow.cells.length)
newCell.innerHTML = '<select name="periodicidad'+(numero)+'" size="1" id="periodicidad"><option>1 hora</option><option>2 horas</option><option>3 horas</option><option>5 horas</option><option>12 horas</option><option>1 dia</option><option>2 dias</option><option>3 dias</option><option>1 semana</option><option>2 semanas</option><option>1 mes</option><option>2 meses</option><option>3 meses</option><option>6 meses</option><option>1 año</option></select>'
document.form1.ntabla.value=numero;
}
function removeLastRow()
{
var TABLE = document.getElementById("tabla");
if(TABLE.rows.length> 4)
{
TABLE.deleteRow(TABLE.rows.length-1);
--numero;
}
else
alert("El Formulario debe contener al menos una meta")
}
</script>
<body>
<form action="almacenar.php" method="post" name="form1" id="form1">
<div align="center">
<table width="1141" id="tabla" border="1"">
<tr class="celda">
<td colspan="9""><div align="center">tabla</div></td>
</tr>
<tr>
<td width="37" rowspan="2"><div align="center" class="Estilo2">No.</div></td>
<td width="468" rowspan="2"><div align="center" class="Estilo2">promesa</div></td>
<td width="474" rowspan="2"><div align="center" class="Estilo2">logro</div></td>
<td width="134" rowspan="2"><div align="center" class="Estilo2">duracion</div></td>
</tr>
<tr>
</tr>
<tr id="celda" class="celda">
<td height="50" bordercolor="#000000"><div align="center">1</div> </td>
<td bordercolor="#000000">
<textarea name="metas1" cols="45" rows="3" id="metas" style=" overflow:hidden"></textarea> </td>
<td bordercolor="#000000">
<label>
<textarea name="compromisos1" id="compromisos" style=" overflow:hidden" cols="45" rows="3"></textarea>
</label> </td>
<td bordercolor="#000000">
<select name="periodicidad1" size="1" id="periodicidad">
<option>1 hora</option>
<option>2 horas</option>
<option>3 horas</option>
<option>5 horas</option>
<option>12 horas</option>
<option>1 dia</option>
<option>2 dias</option>
<option>3 dias</option>
<option>1 semana</option>
<option>2 semanas</option>
<option>1 mes</option>
<option>2 meses</option>
<option>3 meses</option>
<option>6 meses</option>
<option>1 año</option>
</select> </td>
</tr>
</table>
<input type="button" class="boton" value="Nueva Meta" onClick="addNewRow(event)" alt="Adicionar" />
<input type="button" class="boton" value="Eliminar Meta" onClick="removeLastRow(event)" alt="Remover">
</div>
<input type="hidden" name="ntabla" id="ntabla" value=1 />
<p align="center"><input type="SUBMIT"><input type="reset"></p>
</form>
</body>
</html>
lo que necesito es saber cuantas variables se crean en total para esto intente enviar la variable numero que se crea en el js
Código:
document.form1.ntabla.value=numero;