I am quite new to jquery and am gradually working through my book! I have generated this simple calculator for some form field values. Basically if the user select percentage a pecentage calculation occurs and the results are put into another form field. If the user selects mvalue the script just places that value into the form field instead. The percentage calculator works perfectly, the problem is with the second part of the script, the error message in firefox is calcVal.toFixed is not a function. My apologies if this code is overkill or chunky, but as i say i am still learning.
<script type="text/javascript">
function myCalc() {
var selectVal = $('##txt_passoc_type#currentrow# :selected').val();
var valBox = $('##mon_value#currentrow#').val();
var currentPrice = $('##currentPrice#currentrow#').val();
if (selectVal == "Percentage"){
var calcVal = ((currentPrice * valBox)/100);
var myTotal = currentPrice - calcVal;
var myCleanTotal = myTotal.toFixed(2);
$('##mon_paasoc_dprice#currentrow#').val(myCleanTotal);
$('##screenPrice#currentrow#').val(myCleanTotal);
}
else if (selectVal == "MValue"){
var myVal = $('##mon_value#currentrow#').val();
var calcVal = myVal
var myTot = calcVal.toFixed(2);
$('##mon_paasoc_dprice#currentrow#').val(myVal);
$('##screenPrice#currentrow#').val(myVal);
}
}
</script>
Any help is appreciated.
Jason