<?PHP
echo "<script type=\"text/javascript\">\n";echo "<!--\n";echo "var suma; suma=0;\n";
echo "function calculadis(f){\n";
echo "suma = eval(f.pro1.value)+eval(f.pro2.value)+eval(f.pro3.value)+eval(f.pro4.value)+eval(f.pro5.value)+eval(f.pro6.value)+eval(f.pro7.value)+eval(f.pro8.value)+eval(f.pro9.value)+eval(f.pro10.value)\n";
echo "f.tpers.value=suma;}\n";
echo "//-->\n";echo "</script>\n";
if(!$_POST)
{
echo "<FORM NAME=\"disesp\" METHOD=\"POST\" ACTION=".$_SERVER['PHP_SELF']." >\n";
?>
<table border="0" cellspacing="0" width="100%" >
<tr><td width="100%" align="center" colspan="14" height="15"></td></tr>
<td width="100%" align="center" colspan="14" height="15">
<font color="#FFFFFF"><H4>Añadiendo Temperaturas
</td></tr><tr><td width="100%" align="center" colspan="14" height="15">
</td></tr></table>
<table border="1" cellspacing="1" width="100%" height="100">
<tr></center></p></td>
<?php
$j=7;
echo "<tr><td width=\"100%\" height=\"5\" colspan=\"23\"><h4><p align=\"center\">\n";
echo "introduzca el codigo de provincia y las temperaturas</td></tr><h5>\n";
for ($i = 1; $i < 11;$i++):
$j++;
If ($j>5) {
echo "<tr>\n";
$j=0;}
$Indice="$Ind".$i;
$Prov="$pro".$i;
echo "<td width=\"1%\"></td>\n";
echo "<p align=\"center\"><td width=\"2%\">Prov : <input type =\"text\" size=\"2\" value=\"$_POST[$Indice]\" name=\"Ind$i\"></td>\n";
if (($_POST["$Pro".$i])=="" ) {$Valor=0;}
else {$Valor=$_POST["$Pro".$i];}
echo "<p align=\"center\"><td width=\"4%\">Temp :
<input type =\"text\" size=\"5\" value=\"$Valor\" name=\"pro$i\" onchange=\"calculadis(this.form,$i)\"></td><td width=\"1%\"></td>\n";
If ($j==5) {echo "</tr>\n";}
endfor;
echo "<td width=\"1%\"></td><td width=\"2%\"></td>\n";
echo "<td width=\"4%\"></td><td width=\"1%\"></td></tr>\n";
echo "<tr><td width=\"72%\" height=\"5\" colspan=\"23\"><center>Total España : <input size=\"15\" name=\"tpers\" readonly value=0></td><td width=\"1%\"></td></tr>\n";
?>
</table>
<table border="1" cellspacing="0" width="100%" >
<tr><td width="100%" align="center" colspan="14" height="5">
</td></tr></table>
<table border="1" cellspacing="0" width="100%" >
<tr><td width="100%" align="center" colspan="14" height="5">
<input type="SUBMIT" name="botonenvio" value="Añadir Datos">
<input type="RESET" name="Borrar" value="Reset" onClick="Reset()">
</p></td></tr></table></FORM>
<?PHP
}
else
{
// se grabarian los datos en las tablas
}
?>