i'm learning JavaScript and am working on a JavaScript function to calculate discount based on type of buyer i.e retailer/wholesaler & if it's cash or check payment. Here is the function
<script>
function sell()
{
var gross,net,tax,discount,unitprice,quatity,select2,select3;
unitprice=parseInt(form9.unitprice.value);
quantity=parseInt(form9.quantity.value);
select3=parseInt(form9.select3.value);
select2=parseInt(form9.select2.value);
gross=parseInt(form9.gross.value);
gross=unitprice*quantity
form9.gross.value=gross;
tax=0.16*gross
form9.tax.value=tax;
if(select2='Cash' && select3='Retailer')
discount=0.07*gross;
else if(select2='Cash' && select3='Wholesaler')
discount=0.1*gross;
else if(select2='Check')
discount=0*gross;
form9.discount.value=discount;
net=(gross-(discount+tax));
form9.net.value=net;
}
</script>
I created a dropdown menu for type of buyer, named it select2
<select name="select2">
<?php
do {
?>
<option value="<?php echo $row_rsCustomercategory['type']?>"><?php echo $row_rsCustomercategory['type']?></option>
<?php
} while ($row_rsCustomercategory = mysql_fetch_assoc($rsCustomercategory));
$rows = mysql_num_rows($rsCustomercategory);
if($rows > 0) {
mysql_data_seek($rsCustomercategory, 0);
$row_rsCustomercategory = mysql_fetch_assoc($rsCustomercategory);
}
?>
</select>
The select menu for type of sale is select3
<select name="select3" id="select3">
<?php
do {
?>
<option value="<?php echo $row_rsSaletype['type']?>"><?php echo $row_rsSaletype['type']?></option>
<?php
} while ($row_rsSaletype = mysql_fetch_assoc($rsSaletype));
$rows = mysql_num_rows($rsSaletype);
if($rows > 0) {
mysql_data_seek($rsSaletype, 0);
$row_rsSaletype = mysql_fetch_assoc($rsSaletype);
}
?>
</select>
Cash sales are discount at 7% retailer and 10% wholesaler, no discount for payment by check.
The Problem is that: Upon viewing in a browser and clicking on the "Calculate" button nothing happens. Why is this? I would appreciate any help whatsoever.