Ndertoni nje buxhet online permes te cilit perdoruesit fillimisht te kene mundesi te percaktojne nje numer rreshtash dhe ne klikim te butonit submit,
te shfaqet nje tabele me rreshta numrin e dhene nga perdoruesi dhe 3 kolona perkatesisht emrin e artikullit, sasine dhe cmimin e tij. Rreshti fundit do te permbaje buton shto rresht qe shton nje rresht te ri ne tabele, nje buton llogarit ne klikim te te cilit vendoset totali i shumes, sasi*cmim per cdo artikull, ne fushen e textit te ketij rreshti.
<html>
<?php
if(!isset($_POST['rreshta'])) {
?>
<body>
<form action="buxhet.php" method="POST">
<input type="text" name="rreshta">
<input type="submit" value="dergo">
</form>
<?php
}
else {
$rreshta = $_POST['rreshta'];
?>
<head>
<script type="text/javascript">
function llogarit() {
var total = 0;var i;
for(i=1; i<= <?php echo $rreshta; ?>; i++) total += document.getElementById("sasia"+i).value * document.getElementById("cmimi"+i).value;
document.getElementById("total").value = total;
}
</script>
</head>
<body>
<form action="buxhet.php" method="POST">
<input type="hidden" name="rreshta" id="rreshta" value="<?php echo $rreshta+1; ?>">
<table width="500px" border='1'>
<tr>
<td>Artikulli</td><td>Sasia</td><td>Cmimi</td>
</tr>
<?php
for($i=1; $i<=$rreshta; $i++) {
$artikull = isset($_POST['artikull'.$i])?$_POST['artikull'.$i]:'';
echo " <tr><td><input type='text' id='artikull".$i."' name='artikull".$i."' value='".$artikull."'></td>";
$sasia = isset($_POST['sasia'.$i]) ? $_POST['sasia'.$i] : 0;
echo "<td><input type='text' id='sasia".$i."' name='sasia".$i."' value='".$sasia."'></td>";
$cmimi = isset($_POST['cmimi'.$i]) ? $_POST['cmimi'.$i] : 0;
echo "<td><input type='text' id='cmimi".$i."' name='cmimi".$i."' value='".$cmimi."'></td></tr>";
}
?>
<tr>
<td><input type="submit" value="shto rresht"></td>
<td><input type="button" value="llogarit" onClick="llogarit()"></td>
<td><input type="text" id="total" name="total"></td>
</tr>
</table>
</form>
<?php
}
?>
</body></html>