Webboy2008
asked on
javascript client codes on mvc/razor
I extract the code from mvc/razor. But this is more like js question.
Just want to know why document.getElementById("f eeTotal"). value SOMETIME has wrong total amount.
My goal is to get the grand total amount from the fee item (I have the item cost stored in the database so I use razor to loop it back) and I allow user to add qty.
Just want to know why document.getElementById("f
My goal is to get the grand total amount from the fee item (I have the item cost stored in the database so I use razor to loop it back) and I allow user to add qty.
<div class="col-md-6">
<table width="100%" cellpadding="3" cellspacing="3">
<tr style="font-weight:900;">
<td>Fee Description</td>
<td>Unit Price</td>
<td>Qty</td>
<td>Total Cost</td>
</tr>
@{
//public List<Domain.FleetFee> FleetFeeList
foreach (Domain.FleetFee item in mh.FleetFeeList("9", "Active"))
{
<tr>
<td><input type="text" style="text-align:left;font-weight:900;" readonly id="valueFeeDescription_@item.feeId" value="@item.feeDescription" /></td>
<td><input type="text" style="text-align:right;font-weight:900;" readonly id="valueFeeCost_@item.feeId" value="@item.cost" /></td>
<td><input type="text" style="text-align:right;font-weight:900;" onchange="CalculatorFeeItem(valueFeeCost_@item.feeId,this,subFeeTotalCost_@item.feeId)" id="Qty_@item.feeId" /></td>
<td><input type="text" style="text-align:right;font-weight:900;" readonly id="subFeeTotalCost_@item.feeId" /></td>
</tr>
}
}
<tr>
<td colspan="2"><br /></td>
<td style="text-align:right;"></td>
<td><input type="text" style="text-align:right;font-weight:900;" id="feeTotal" value="0.00" /></td>
</tr>
</table>
<script>
function CalculatorFeeItem(cost, qty, feetotalamount)
{
feetotalamount.value = parseFloat((parseFloat(cost.value) * parseFloat(qty.value))).toFixed(2);
document.getElementById("feeTotal").value = parseFloat(parseFloat(document.getElementById("feeTotal").value) + parseFloat(feetotalamount.value)).toFixed(2);
}
</script>
</div>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Auto Close