Ah I didnt explain it well, sorry. I have done my HW, but wanted to put this because i tough it was cool, well anyways tyvm for reply m8 ๐
After searching online for similar codes, i finally understood it and managed to get it running ๐ . If anybody is interested here is a code (names are written in my language but you'll understand ๐ )
1st ive added this in head:
<SCRIPT language=JavaScript>
function Estimate(form) {
var rukavice = form.rukavice.value;
var kimono = form.kimono.value;
var stitnici = form.stitnici.value;
var TotalCostRukavice = (rukavice * 125);
var TotalCostKimono = (kimono * 300);
var TotalCostStitnici = (stitnici * 85);
var TotalCost = TotalCostRukavice + TotalCostKimono + TotalCostStitnici;
form.TotalCostRukavice.value = RoundToPennies(TotalCostRukavice);
form.TotalCostKimono.value = RoundToPennies(TotalCostKimono);
form.TotalCostStitnici.value = RoundToPennies(TotalCostStitnici);
form.TotalCost.value = RoundToPennies(TotalCost);
}
function RoundToPennies(n) {
pennies = n * 100;
pennies = Math.round(pennies);
strPennies = "" + pennies;
len = strPennies.length;
return strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len);
}
</SCRIPT>
and this is my whole form:
<form name="form1" method="post" action="narudzba.php">
<table width="400" border="0" cellspacing="0" cellpadding="4">
<tr>
<td>Artikal</td>
<td>Količina</td>
<td>Cijena:</td>
</tr>
<tr>
<td>Rukavice (<font color="red">125</font> kuna par)</td>
<td><INPUT name=rukavice type="text" id="rukavice" maxLength=4 onchange=javascript:Estimate(this.form); size=6> </td>
<td><input maxlength=9 name=TotalCostRukavice readOnly size=6>
</td>
<td>Kuna</td>
</tr>
<tr>
<td>Kimono (<font color="red">300</font> kuna komad)</td>
<td><INPUT maxLength=4 name=kimono id="kimono" onchange=javascript:Estimate(this.form); size=6> </td>
<td><input maxlength=9 name=TotalCostKimono readOnly size=6>
</td>
<td>Kuna</td>
</tr>
<tr>
<td>ล titnici (<font color="red">85</font> kuna par)</td>
<td><INPUT maxLength=4 name=stitnici id="stitnici" onchange=javascript:Estimate(this.form); size=6> </td>
<td><input maxlength=9 name=TotalCostStitnici readOnly size=6>
</td>
<td>Kuna</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input maxlength=9 name=TotalCost readOnly size=6> </td>
<td>Kuna</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Naruči">
</td>
<td> </td>
</tr>
</table>
</form>