GUARDA BENE COME HO CHIAMATO I CAMPI E COME RICHIAMO LE FUNZIONI SOMMA E PERCENT
A1_0 è il primo campo del primo consigliere
A1_1 è il secondo campo del primo consigliere
A1_somma è il campo somma del primo consigliere
A1_percent è il campo percentuale del primo consigliere
ecco il codice
<html>
<head>
<script>
function somma(cons) {
for(var i=0,tot=0; document.form1.elements["A"+cons+"_"+i]; i++) {
tot += parseInt(document.form1.elements["A"+cons+"_"+i].value)?parseInt(document.form1.elements["A"+cons+"_"+i].value):0;
}
document.form1.elements["A"+cons+"_somma"].value = tot;
}
function percent(cons) {
for(var i=1,tot=0; document.form1.elements["A"+i+"_somma"]; i++) {
somma(i);
tot += parseInt(document.form1.elements["A"+i+"_somma"].value)?parseInt(document.form1.elements["A"+i+"_somma"].value):0;
}
document.form1.elements["A"+cons+"_percent"].value = (Math.round(document.form1.elements["A"+cons+"_somma"].value*100/tot)?Math.round(document.form1.elements["A"+cons+"_somma"].value*100/tot):0) + " %";
}
</script>
</head>
<body onresize="if (document.layers) top.location.reload()" bgcolor="#F0F1F2"
leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" alink="#000000" vlink="#000000" link="#000000" style="background-color: #FFFFFF">
<div align="center">
<table border="0" cellpadding="0" style="border-collapse: collapse" width="766" id="table3">
<tr>
<td> </td>
</tr>
<tr>
<td>
<p align="center"><font size="2">LISTA NUMERO 1</font></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</div>
<div align="left">
</div>
<div align="center">
<table border="0" cellpadding="0" style="border-collapse: collapse" width="763" id="table2" height="490" bordercolor="#000000">
<tr>
<td valign="top"></td>
</tr>
<tr>
<td valign="top"><form method="POST" action="<%Aggiungi%>" name="form1">
<div align="center">
<table border="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC" width="646">
<tr valign="baseline">
<td nowrap align="right" width="178"> </td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez1</font></td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">2</font></td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">3</font></td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">4</font></td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">5</font></td>
<td width="26" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">6</font></td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">7</font></td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">8</font></td>
<td width="32" bordercolor="#000000" align="center">
<font size="1">Sez</font><font size="1">9</font></td>
<td width="34" bordercolor="#000000" align="center">
<p align="center">
<font size="1">Sez10</font></td>
<td width="32" bordercolor="#000000" align="center">
<p align="center">
<font size="1">Tot</font></td>
<td width="32" bordercolor="#000000" align="center">
<p align="center">
<font size="1">%</font></td>
</tr>
<tr>
<td nowrap align="right" width="178"> </td>
<td width="32" align="center">
</td>
<td width="32" align="center">
</td>
<td width="32" align="center">
</td>
<td width="32" align="center">
</td>
<td width="32" align="center">
</td>
<td width="26" align="center">
</td>
<td width="32" align="center">
</td>
<td width="32" align="center">
</td>
<td width="32" align="center">
</td>
<td width="34" align="center">
</td>
<td width="32" align="center">
</td>
<td width="32" align="center">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" width="503" valign="middle" colspan="11">
<font color="#3282BC"> </font></td>
<td nowrap align="center" width="32" valign="middle">
</td>
<td nowrap align="center" width="32" valign="middle">
</td>
</tr>
<tr>
<td nowrap align="right" width="178"><font color="#3282BC">
<font size="2">CONSIGLIERE 1</font>:</font></td>
<td width="32" align="center">
<input type="text" name="A1_0" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_1" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_2" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_3" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_4" size="4"></td>
<td width="26" align="center">
<input type="text" name="A1_5" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_6" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_7" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_8" size="4"></td>
<td width="34" align="center">
<input type="text" name="A1_9" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_somma" size="4"></td>
<td width="32" align="center">
<input type="text" name="A1_percent" size="4"></td>
<td><input type="button" value=" + " onclick="somma(1);"></td>
<td><input type="button" value=" % " onclick="percent(1);"></td>
</tr>
<tr>
<td nowrap align="right" width="178"><font color="#3282BC">
<font size="2">CONSIGLIERE 2</font>:</font></td>
<td width="32" align="center">
<input type="text" name="A2_0" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_1" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_2" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_3" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_4" size="4"></td>
<td width="26" align="center">
<input type="text" name="A2_5" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_6" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_7" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_8" size="4"></td>
<td width="34" align="center">
<input type="text" name="A2_9" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_somma" size="4"></td>
<td width="32" align="center">
<input type="text" name="A2_percent" size="4"></td>
<td><input type="button" value=" + " onclick="somma(2);"></td>
<td><input type="button" value=" % " onclick="percent(2);"></td>
</tr>
<tr>
<td nowrap align="right" width="178"><font color="#3282BC">
<font size="2">CONSIGLIERE 3</font>:</font></td>
<td width="32" align="center">
<input type="text" name="A3_0" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_1" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_2" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_3" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_4" size="4"></td>
<td width="26" align="center">
<input type="text" name="A3_5" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_6" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_7" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_8" size="4"></td>
<td width="34" align="center">
<input type="text" name="A3_9" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_somma" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_percent" size="4"></td>
<td><input type="button" value=" + " onclick="somma(3);"></td>
<td><input type="button" value=" % " onclick="percent(3);"></td>
</tr>
<tr>
<td nowrap align="right" width="178"> </td>
<td width="32" align="center">
<input type="text" name="A13" size="4"></td>
<td width="32" align="center">
<input type="text" name="A14" size="4"></td>
<td width="32" align="center">
<input type="text" name="A15" size="4"></td>
<td width="32" align="center">
<input type="text" name="A16" size="4"></td>
<td width="32" align="center">
<input type="text" name="A17" size="4"></td>
<td width="26" align="center">
<input type="text" name="A18" size="4"></td>
<td width="32" align="center">
<input type="text" name="A19" size="4"></td>
<td width="32" align="center">
<input type="text" name="A20" size="4"></td>
<td width="32" align="center">
<input type="text" name="A21" size="4"></td>
<td width="34" align="center">
<input type="text" name="A22" size="4"></td>
<td width="32" align="center">
<input type="text" name="somma4" size="4"></td>
<td width="32" align="center">
<input type="text" name="A3_perc0" size="4"></td>
</tr>
<tr valign="baseline">
<td nowrap align="center" width="629" colspan="13">
</td>
</tr>
</table>
</div>
<input type="hidden" name="Aggiungi" value="true">
</form>
</td>
</tr>
</table>
</div>
</body>
</html>

Rispondi quotando
