Una vez mas yo
quiero consultarles tengo este codigo pero al iniciar el formulario me muestra el mensaje no cobras lcr por ser menor a 6 eso es solo al correr el script y cuando le doy calcular me borra los datos ingresados en los input como puedo evitar esto???? y si hay alguna forma de ahorrarme tanto if???
Código PHP:
Ver original
<html> <head> <style type="text/css"> .miclase {text-align:center} </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Calculador Incentivos</title> </head> <body> <?php //daclaro variables de formulario $uniadsl =(float) $_POST['adsl']; $uniimg =(float) $_POST['img']; $unibam =(float) $_POST['bam']; $lcrc =(float) $_POST['lcr']; $tmoc =(float) $_POST['tmo']; $asjc =(float) $_POST['asj']; // valor de adsl, img, bam en variables $preadsl = 15; $preimg = 20; $prebam = 5; // total varibales form con valor de variables $totadsl = $uniadsl * $preadsl; $totimg = $uniimg * $preimg; $totbam = $unibam * $prebam; //calculo precio promedio if($lcrc < 6.5 ){ echo "<p style='color:#FF0000'>No cobras Lcr por ser Menor a 6.5</p>"; $lcrmsg = '---'; // 10% }else if($lcrc == 6.5 ){ $lcrmsg = 20; // 10% }else if($lcrc == 6.6){ $lcrmsg = 40; //20% }else if($lcrc == 6.7 ){ $lcrmsg = 60; //50% }else if($lcrc == 6.8 ){ $lcrmsg = 80; //50% }else if($lcrc == 6.9 ){ $lcrmsg = 100; //50% }else if($lcrc == 7 ){ $lcrmsg = 120; //50% }else if($lcrc == 7.1 ){ $lcrmsg = 140; //50% }else if($lcrc == 7.2 ){ $lcrmsg = 160; //50% }else if($lcrc == 7.3 ){ $lcrmsg = 180; //50% }else if($lcrc == 7.4 ){ $lcrmsg = 200; //50% }else if($lcrc == 7.5 ){ $lcrmsg = 220; //50% }else if($lcrc == 7.6 ){ $lcrmsg = 240; //50% }else if($lcrc == 7.7 ){ $lcrmsg = 260; //50% }else if($lcrc == 7.8 ){ $lcrmsg = 280; //50% }else if($lcrc == 7.9 ){ $lcrmsg = 300; //50% }else if($lcrc == 8 ){ $lcrmsg = 320; //50% }else if($lcrc == 8.1 ){ $lcrmsg = 340; //50% }else if($lcrc == 8.2 ){ $lcrmsg = 360; //50% }else if($lcrc == 8.3 ){ $lcrmsg = 380; //50% }else if($lcrc == 8.4 ){ $lcrmsg = 400; //50% }else if($lcrc == 8.5 ){ $lcrmsg = 420; //50% }else if($lcrc == 8.6 ){ $lcrmsg = 440; //50% }else if($lcrc == 8.7 ){ $lcrmsg = 460; //50% }else if($lcrc == 8.8 ){ $lcrmsg = 480; //50% }else if($lcrc == 8.9 ){ $lcrmsg = 500; //50% }else if($lcrc == 9 ){ $lcrmsg = 500; //50% }else if($lcrc > 10 ){ echo "<p style='color:#FF0000';>El Numero Ingresado debe Ser Menor a 10</p>"; $lcrmsg = 'error'; //50% } echo "<form action='incentivos.php' method='post'>"; echo "Selecciona Tu Modo"; echo "<select name 'modo'>"; echo "<OPTION VALUE='desa'>Desarrollo</OPTION> "; echo "<OPTION VALUE='fide'>Fidelizacion</OPTION> "; echo "<OPTION VALUE='preve'>Prevencion</OPTION> "; echo "</select>"; echo "<p>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "Ingresa tu LCR <input type='text' name='lcr' size='4'><br><br>"; echo "<p><h1>Unidades vendidas</h1></p><br>"; echo "<p style='margin-left:25px; margin-top:-15px;'> Adsl Imagenio Bam<br>"; echo "<input type='text' name='adsl' size='4'> <input type='text' name='img' size='4'> <input type='text' name='bam' size='4'><br></p><br><br>"; echo "Ingresa tu TMO <input type='text' name='tmo' size='4'> ASJ'S <input type='text' name='asj' size='4'><br><br><br><br />"; echo "<table border='1'>"; echo "<tr >"; echo "<td rowspan='3'>Precio Promedio</td>"; echo "</tr>"; echo "<tr align='center'>"; echo "<td colspan='3' >Ventas</td>"; echo "<td colspan='2' >Acelerador</td>"; echo "</tr>"; echo "<tr align='center'>"; echo "<td>Adsl</td>"; echo "<td>Imagenio</td>"; echo "<td>Bam</td>"; echo "<td>Tmo</td>"; echo "<td>Lcr</td>"; echo "</tr>"; echo "<tr>"; echo "<td><input type='text' class='miclase' name='resuladsl' size='15' readonly value='Q $lcrmsg'></td>"; echo "<td><input type='text' class='miclase' name='resuladsl' size='4' readonly value='Q $totadsl'></td>"; echo "<td><input type='text' class='miclase' name='resulimg' size='7' readonly value='Q $totimg''></td>"; echo "<td><input type='text' class='miclase' name='resulbam' size='4' readonly value='Q $totbam'></td>"; echo "<td><input type='text' class='miclase' name='resultmo' size='4' readonly ></td>"; echo "<td><input type='text' class='miclase' name='resullcr' size='4' readonly ></td>"; echo "</tr>"; echo "</table><br><br>"; echo "<table border='1'>"; echo "<tr>"; echo "<td>Total Incentivo</td>"; echo "</tr>"; echo "<tr>"; echo "<td ><input type='text' class='miclase' name='totincentivo' size='10' disabled='disabled' value=''></td>"; echo "</tr>"; echo "</table>"; echo "</table><br><br>"; echo "<table border='1'>"; echo "<tr>"; echo "<td>Por Ausencias has perdido</td>"; echo "</tr>"; echo "<tr>"; echo "<td ><input type='text' class='miclase' name='totincentivo' size='22' disabled='disabled' value=''></td>"; echo "</tr>"; echo "</table><br><br>"; echo "<input type='submit' value='Calcular'>"; ?> </body> </html>
Gracias y Saludos