najaru Posted September 21, 2013 Report Share Posted September 21, 2013 Hi Michael, hi all I've a simple php code, for take simple data , make calcule, and print the result. here my code. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Calcolo</title> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" > </head> <body> <?php if (isset ($_POST['val_a']) && isset ($_POST['val_b']) && isset ($_POST['val_c'])) { $a = (float) $_POST['val_a']; $b = (float) $_POST['val_b']; $c = (float) $_POST['val_c']; $risultato = @($a * $b / $c); if ($risultato !== FALSE) echo "Risultato di A*B/C = " . $risultato . "<br><br>"; else echo "Errore nel calcolo<br><br>"; } ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <p> Valore A <input id="val_a" type="text" name="val_a" size="20" maxlength="20" value="<?php echo htmlspecialchars ($_POST['val_a'], ENT_QUOTES); ?>"> <br> Valore B <input id="val_b" type="text" name="val_b" size="20" maxlength="20" value="<?php echo htmlspecialchars ($_POST['val_b'], ENT_QUOTES); ?>"> <br> Valore C <input id="val_c" type="text" name="val_c" size="20" maxlength="20" value="<?php echo htmlspecialchars ($_POST['val_c'], ENT_QUOTES); ?>"> <br> <input type="submit" value="Calcola"> </p> </form> </body> </html> i need to multiply the result for a SPECIFIC FACTOR, dependent by value select by user in dropdown $risultato = @($a * $b / $c) * FACTOR; in dropdown for example: RED (FACTOR=1) GREEN (FACTOR=1,3456) BLUE (FACTOR=3,2965) then user can choice Red Blue or green in dropdown does is difficult? Quote Link to comment Share on other sites More sharing options...
Management Michael Posted September 22, 2013 Management Report Share Posted September 22, 2013 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Calcolo</title> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" > </head> <body> <?php if (isset ($_POST['val_a']) && isset ($_POST['val_b']) && isset ($_POST['val_c'])) { $a = (float) $_POST['val_a']; $b = (float) $_POST['val_b']; $c = (float) $_POST['val_c']; $risultato = @($a * $b / $c)*$_POST['factor']; if ($risultato !== FALSE) echo "Risultato di A*B/C = " . $risultato . "<br><br>"; else echo "Errore nel calcolo<br><br>"; } ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <p> Valore A <input id="val_a" type="text" name="val_a" size="20" maxlength="20" value="<?php echo htmlspecialchars ($_POST['val_a'], ENT_QUOTES); ?>"> <br> Valore B <input id="val_b" type="text" name="val_b" size="20" maxlength="20" value="<?php echo htmlspecialchars ($_POST['val_b'], ENT_QUOTES); ?>"> <br> Valore C <input id="val_c" type="text" name="val_c" size="20" maxlength="20" value="<?php echo htmlspecialchars ($_POST['val_c'], ENT_QUOTES); ?>"> <br> Factor <select name='factor'><option value='1'>RED</option><option value='1.3456'>GREEN</option><option value='3.2965'>BLUE</option></select> <br> <input type="submit" value="Calcola"> </p> </form> </body> </html> Might want to clean up and test the code a bit but try this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.