I wrote a script in php. It’s very simple, it just multiplies a typed in number and adds another number to it. But I don’t know how to convert it to js.
From the form on my html page, I submit the kilometers and the script calculates the cost of this ride (it’s a taxi company).
<form action="http://www.mydomain.de/action.php" class="box style" method="post" target="_blank">
<fieldset>
<legend>Jetzt berechnen:</legend>
<div style="float: left;"><label for="km">KM-Eingabe</label> <input name="km" type="Text"></div><div><input src="/images/berechnen.png" alt="berechnen" type="image"></div>
</fieldset>
</form>
The php script is this:
<p>
Sie haben angegeben, dass die geplante Fahrt <?php echo $_POST["km"];?> km beträgt.
<br />
Im Tagtarif (werktags 06-22 Uhr) kostet die angefragte Fahrt <?php $km=$_POST["km"]; echo $km * 1.7 + 2.2; ?> EURO.
<br />
Im Nachttarif / Sonn- und Feiertags (werktags 22-06 Uhr) kostet die angefragte Fahrt <?php $km=$_POST["km"]; echo $km * 1.8 + 2.2;?> EURO.
</p>
You should probably learn the basics of Javascript, but hopefully this will help you get started