guarda se va
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
// <![CDATA[
function calcola11()
{
/*
var som1= parseFloat(document.form1.tot1.value);
var som2= parseFloat(document.form1.tot2.value);
var som3= parseFloat(document.form1.tot3.value);
var som4= parseFloat(document.form1.tot4.value);
var som5= parseFloat(document.form1.tot5.value);
var tot= parseFloat(document.form1.totimp.value);
var totimp= parseFloat(som1*1+som2*1+som3*1+som4*1+som5*1+tot*1);
document.form1.totimp.value= totimp;
*/
var somma = calcola_somma("tot1", "tot2", "tot3", "tot4", "tot5");
document.getElementById("totimp").value = somma.toString();
}
function calcola_somma()
{
var s = 0;
for(var i = 0; i < arguments.length; i++)
{
var n = null;
var v = arguments[i];
if( typeof(v) == "string" )
{
n = document.getElementById(v).value.replace(/\,/g, ".");
s += ((isNaN(parseFloat(n)))?0:parseFloat(n));
}
else if(v instanceof Array)
{
for(var i = 0; i < v.length; i++)
{
if( typeof(v[i]) == "string" )
n = document.getElementById(v[i]).value.replace(/\,/g, ".");
else
n = (v[i]).value.replace(/\,/g, ".");
s += ((isNaN(parseFloat(n)))?0:parseFloat(n));
}
}
}
return s;
}
// ]]>
</script>
</head>
<body>
<form name="form1" action="fattura5.php" method="get" >
<input type="text" name="tot1" id="tot1" size="5" >
<input type="text" name="tot2" id="tot2" size="5">
<input type="text" name="tot3" id="tot3" size="5">
<input type="text" name="tot4" id="tot4" size="5">
<input type="text" name="tot5" id="tot5" size="5">
<input type="text" name="totimp" id="totimp" size="12" value="<?php echo $totimp; ?>" onchange="calcola11(2)";>
Calcola
</form>
</body>
</html>