Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/09/2010, 20:41
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 14 años, 2 meses
Puntos: 6
como validar campos en una tabla dinamica---sumar o multipli inputs de la tabla dinam

<html>
<head>
<SCRIPT>
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Jim Stiles | www.jdstiles.com */
function startCalc(){
interval = setInterval("calc()",1);
}
function calc(){
one = document.autoSumForm.firstBox.value;
two = document.autoSumForm.secondBox.value;
document.autoSumForm.thirdBox.value = (one * 1) * (two * 1);
}
function stopCalc(){
clearInterval(interval);
}
</SCRIPT>

<script type="text/javascript">
var contLin = 3;
function agregar() {
var tr, td, tabla;

tabla = document.getElementById('tabla');
tr = tabla.insertRow(tabla.rows.length);
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<select id='sel" + contLin + "'>" +
"<option>1" +
"<option>2" +
"<option>3";
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' id='t" + contLin + "1'>";
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' id='t" + contLin + "2'>";
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' id='t" + contLin + "2'>";
contLin++;
}
function borrarUltima() {
ultima = document.all.tabla.rows.length - 1;
if(ultima > -1){
document.all.tabla.deleteRow(ultima);
contLin--;
}
}
</script>
</head>
<body>
<form id="autoSumForm" name="autoSumForm" method="post" action="">
<table id="tabla" border="1">
<tr>
<td><select name="sel1" id="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
</select> </td>
<td><input id="firstBox" name="firstBox" type="text" class="right" onfocus="startCalc();" onblur="stopCalc();"/></td>
<td><input name="secondBox" type="text" class="right" id="secondBox" onfocus="startCalc();" onblur="stopCalc();"/></td>
<td><input class="right" type="text" name="thirdBox" readonly="" /></td>
</tr>
</table>
<br>
<input type="button" value="Agregar" onclick="agregar()">
<input type="button" value="Borrar ultima" onclick="borrarUltima()">
</form>
</body>
</html>