PHP - no suma automatica en 2 fila

   
Vista:

no suma automatica en 2 fila

Publicado por Jhean Carlos (113 intervenciones) el 03/06/2011 21:33:45
hola tengo un problema.

el codigo que tengo no suma la segunda fila, la primera fila funciona bien con el script pero aplicando otro script con algunos cambios no funciona en la segunda fila

aqui les muestro el codigo





<script language="JavaScript">
var nav4 = window.Event ? true : false;
function acceptNum(evt)
{
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key>= 48 && key <= 57));
}
</script>

<script>
function sumar()
{
total=0;
for(a=0;a<12;a++)
{
document.forms[0].elements[a].value=document.forms[0].elements[a].value.split(",").join(".");
if (!isNaN(document.forms[0].elements[a].value))
{
pepe=new Number(document.forms[0].elements[a].value);
total=total+pepe;
document.forms[0].elements["total"].value=total
}
else
{
document.forms[0].elements[a].value=""
///alert ("No introdusca letras, solo se admiten Números.");
}
}
}
</script>
<script>
function sumarq()
{

total=0;
for(a=0;a<12;a++)
{
document.forms[0].elements[a].value=document.forms[0].elements[a].value.split(",").join(".");
if (!isNaN(document.forms[0].elements[a].value))
{

pepe=new Number(document.forms[0].elements[a].value);

total=total+pepe;

document.forms[0].elements["total2"].value=total
}
else
{
document.forms[0].elements[a].value=""
///alert ("No introdusca letras, solo se admiten Números.");
}
}
}
</script>

</head>

<style type="text/css">
.textbox_normal { background-color:#FFFFFF; }
.textbox_activado { background-color:#FFFFCC;color:#0000FF }
</style>

<body><table width="388" align="center"><form action="javascript:alert('Enviando')"
name="formularo" id="formularo">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="29">1</td>
<td width="18"><input name="numero1" type="text" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)"></td>
<td width="18"><input name="numero2" type="text" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero3" type="text" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3"onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero4" type="text" id="numero4" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero5" type="text" id="numero5" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero6" type="text" id="numero6" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero7" type="text" id="numero7" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero8" type="text" id="numero8" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero9" type="text" id="numero9" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero10" type="text" id="numero10" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero11" type="text" id="numero11" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="18"><input name="numero12" type="text" id="numero12" style="text-align:right" onKeyUp=sumar() size="3" maxlength="3" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"></td>
<td width="36"><input name="total" type="text" style="text-align:right" size="6" maxlength="6" readonly></td>
<td width="36">&nbsp;</td>
<td width="560"><label></label></td>
</tr>
<tr>
<td>2</td>
<td><input name="n1" type="text" id="n1" style="text-align:right" onKeyUp=sumarq() onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" size="3" maxlength="3"></td>
<td><input name="n2" type="text" id="n2" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n3" type="text" id="n3" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n4" type="text" id="n4" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n4" type="text" id="n4" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n5" type="text" id="n5" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n6" type="text" id="n6" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n7" type="text" id="n7" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n8" type="text" id="n8" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n9" type="text" id="n9" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n10" type="text" id="n10" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="n11" type="text" id="n11" style="text-align:right" onFocus="this.className='textbox_activado'" onBlur="this.className='textbox_normal'"onKeyPress="return acceptNum(event)" onKeyUp=sumarq() size="3" maxlength="3"></td>
<td><input name="total2" type="text" id="total2" style="text-align:right" size="6" maxlength="6" readonly></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr style="">
<td><label></label></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</form>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve

no suma automatica en 2 fila

Publicado por xve (5512 intervenciones) el 04/06/2011 09:36:07
Hola Jhean, la verdad es que me cuesta mucho seguir tu codigo... recuerda que tienes un boton para añadir código en estos foros...

Nos puedes especificar un poco mas "no suma la segunda fila"

Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

no suma automatica en 2 fila

Publicado por jhean carlos (113 intervenciones) el 06/06/2011 01:11:49
a lo que me refiero son las funciones que tengo en la funcion sumar() todo suma correctamente en las cajas de texto de esa fila, la funcion sumarq() de la segunda fila de cajas de texto no me resulta como en la primera fila

el codigo que dejo lo copian y lo pegan en dreamwever para ver como funciona si no me entendieron.

gracias!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar