hye..
i’m trying to calculate value of balance by substract cash to total. But nothing happen.
here is my code:
[code=html]
<script type=”text/javascript”>
function substract(){
{
document.calculate.Cash.value = ZA;
document.calculate.Total.value = Z1;
balance();
}
function balance(){
AAA = document.calculate.Balance;
AAA.value = (ZA-Z1).toFixed(2);
}
</script>
</head>
<body style=”background-color: #99FF99″>
<?php
// if there are any errors, display them
if ($error != ‘Unable to update’)
{
echo ‘<div style=”padding:12px; border:1px solid purple; color:red; font-weight: bold; text-align: center; font-size: medium; “>’.$error.'</div>’;
}
?>
<form action=”” method=”post” name=”calculate” style=”width: 1320px; “>
<div class=”style1″>
<input type=”hidden” name=”CustID” value=”<?php echo $CustID; ?>”>
<input type=”hidden” name=”Total” value=”<?php echo $Total; ?>”>
<input type=”hidden” name=”TableID” value=”<?php echo $TableID; ?>”>
<div class=”style5″ style=”width: 820px; height: 148px; margin-left: auto; margin-right: auto;”>
<p class=”style9″> </p>
<p class=”style17″><span class=”style19″>CUSTOMER </span> <strong>
<span class=”style19″>ID:</span></strong> <strong> <?php echo $CustID; ?>
</strong></p>
<table style=”width: 35%; height: 185px; margin-left: auto; margin-right: auto;” class=”style15″>
<tr>
<td class=”style11″ style=”width: 111px; height: 30px;”><strong>Table ID :
</strong></td>
<td style=”height: 30px; width: 169px;” class=”style18″><strong><?php echo $TableID; ?></strong></td>
</tr>
<tr>
<td class=”style1″ style=”width: 111px; height: 20px;”></td>
<td style=”height: 20px; width: 169px;” class=”style1″></td>
</tr>
<tr>
<td class=”style16″ style=”width: 111px; height: 30px;”><strong>Total :
</strong></td>
<td style=”height: 30px; width: 169px;” class=”style18″><strong>
RM<?php echo $Total; ?> </strong></td>
</tr>
<tr>
<td class=”style1″ style=”width: 111px; height: 20px;”></td>
<td style=”height: 20px; width: 169px;” class=”style1″></td>
</tr>
<tr>
<td class=”style16″ style=”width: 111px; height: 30px;”><strong>Cash :
</strong></td>
<td style=”height: 30px; width: 169px;” class=”style1″> <strong>
<span class=”style20″>RM</span>
<input type=”text” name=”Cash” id=”Cash” class=”style17″ style=”width: 120px”></strong></td>
</tr>
<tr>
<td class=”style1″ style=”width: 111px; height: 20px;”></td>
<td style=”height: 20px; width: 169px;” class=”style1″></td>
</tr>
<tr>
<td class=”style16″ style=”width: 111px; “><strong>Balance :
</strong></td>
<td style=”width: 169px;” class=”style1″><strong>
<span class=”style20″>RM</span>
<input type=”text” name=”Balance” id=”Balance” value=”0.00″ class=”style17″ style=”width: 120px”></strong></td>
</tr>
</table>
<p class=”style5″><strong>
<input class=”style3″ name=”calculate” type=”button” onclick=”substract()” value=”Calculate”> <input class=”style3″ name=”submit” type=”submit” value=”Done”></strong> </div>
</div>
</form>