http://psp-il.com/percents.phpוהקוד הוא:
<html dir="rtl"> <head> <style> body, table, input { font-family: Arial; font-size: 12px; } </style> </head> <body> <? if($_POST["ok"] == "1") { $ok = true; $msg = "";if(strlen(trim($_POST['number'])) == 0) { $ok = false; $msg .= "<li>לא כתבת את המספר!</li>"; } if(strlen(trim($_POST['percents'])) == 0) { $ok = false; $msg .= "<li>לא כתבת את האחוזים!</li>"; } } ?> <table border=0> <form method="POST"> <input type="hidden" name="ok" value="1"> <tr><td><B>הכנס מספר:</td><td><input value="<? echo $_POST["number"]; ?>" name="number" type="text"></td></tr> <tr><td><B>הכנס את מספר האחזוים:<br></B>ללא " % ".</td><td><input value="<? echo $_POST["percents"]; ?>" name="percents" type="text"></td></tr> <tr><td colspan="2"><center><input type="submit" value="חשב!"></td></tr> </table> <? if($ok) { $number = $_POST["number"]; $percents = $_POST["percents"]; $calc1 = $number * $percents; $calc2 = $calc1 / 100; $calc3 = $number + $calc2; echo "התוצאה היא ".$calc3.""; }else{ echo $msg; } ?> </body> </html>
|