Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/08/2006, 09:24
HemeAqui
 
Fecha de Ingreso: agosto-2006
Mensajes: 44
Antigüedad: 18 años, 6 meses
Puntos: 1
¿Qué tal así?
Código:
<html>
<head>
<title>Offline database</title>
</head>
<style>
.campo {border-width:1px; border-style: solid; border-color:#828282; font-family:verdana; font-size:8pt}
.etiqueta {font-family: verdana; font-size:9pt}
.campo_numerico{border-width:1px; border-style: solid; border-color:#828282; font-family:verdana; font-size:8pt; text-align:right}
</style>
<script>
var r=8; //Máximo de filas.
function addRow()
{
  var o=document.getElementById("cobros");
  var t="<table width=\"100%\" border=\"0\">";
  for (var i=1; i<=r; i++)
  {
    if (document.formulario["fecha"+i]==undefined)
    {
      t+="<tr>";
      t+="<td class=\"etiqueta\">Fecha:</td>";
      t+="<td><input type=text name=\"fecha"+i+"\" class=\"campo\" size=\"12\"></td>";
      t+="<td class=\"etiqueta\">Importe:</td>";
      t+="<td><input type=text name=\"importe"+i+"\" class=\"campo\"></td>";
      t+="<td class=\"etiqueta\">Cod. aut. TPV:</td>";
      t+="<td><input type=text name=\"tpv"+i+"\" class=\"campo\"></td>";
      t+=i==r?"":"<td><input type=\"button\" onclick=\"addRow()\" value=\"+\"></td>";
      t+="</tr>";
      break;
    }
    else
    {
      t+="<tr>";
      t+="<td class=\"etiqueta\">Fecha:</td>";
      t+="<td><input type=text name=\"fecha"+i+"\" value=\""+document.formulario["fecha"+i].value+"\" class=\"campo\" size=\"12\"></td>";
      t+="<td class=\"etiqueta\">Importe:</td>";
      t+="<td><input type=text name=\"importe"+i+"\" value=\""+document.formulario["importe"+i].value+"\" class=\"campo\"></td>";
      t+="<td class=\"etiqueta\">Cod. aut. TPV:</td>";
      t+="<td><input type=text name=\"tpv"+i+"\" value=\""+document.formulario["tpv"+i].value+"\" class=\"campo\"></td>";
      t+="</tr>";
    }
  }
  t+="</table>";
  o.innerHTML=t;
}
</script>
<body style="background-color:#f7f7f7;">
<table align="center">
<tr><td>
<form name="formulario" action="IntroDB.php">
<!-- espacio -->
<table><tr><br></tr></table>
<!-- Cobros -->
<fieldset style="width: 800;">
<LEGEND style="font-family: verdana; font-size:10pt; color:#ff0044">Cobros</LEGEND>
<div id="cobros">
<table width="100%" border="0">
<tr>
<td class="etiqueta">Fecha:</td>
<td><input type=text name="fecha1" class="campo" size="12"></td>
<td class="etiqueta">Importe:</td>
<td><input type=text name="importe1" class="campo"></td>
<td class="etiqueta">Cod. aut. TPV:</td>
<td><input type=text name="tpv1" class="campo"></td>
<td><input type="button" onclick="addRow()" value="+"></td>
</tr>
</table>
</div>
</fieldset>
</form>
</body>
</html>
Básicamente rehace la tabla del formulario cada vez que pulsas el botón '+' con un límite de 8 filas.

Saludos,
HA

Última edición por HemeAqui; 08/08/2006 a las 09:27 Razón: Detallito en el código