Ak chces uzivatelovi este pred odoslanim zobrazit sucet, pouzi js, napr. aj v tejto forme:
Kód:
<script type="text/javascript">
function Sum(form)
{
sum = 0;
elm=form.elements;
for(i=0;i<elm.length-1;i++)
{
elm[i].value=elm[i].value.replace(/\D/g,'');
if (elm[i].value.length>0)
{
sum += parseInt(elm[i].value);
}
}
document.getElementById('total').value= sum;
}
</script>
<form onkeyup="Sum(this);">
<input type="text" name="pole1">
<input type="text" name="pole2">
...
<input type="text" id="total" value="0" readonly="readonly">
</form>