![]() |
| ||
| Help with making decimals show up always I have a page where three funds add up to a total and need it to have decimals, but don't know how to get it to. I need the total to have decimals in the amount field in the form so it will properly pass to the processing website. it adds decimals but they only show up in the total if there is something other than .00. i need the decimals to show up in the total regardless of whether the person entering values into the first 3 fields uses decimals or not. Here is the javascript: <script language="javascript"> function getTotal() { var merchant_defined_field_11, merchant_defined_field_12, merchant_defined_field_13, total; if(document.fund.merchant_defined_field_11.value == '') { merchant_defined_field_11 = 0.00; } else { merchant_defined_field_11 = parseFloat(document.fund.merchant_defined_field_11.value); } if(document.fund.merchant_defined_field_12.value == '') { merchant_defined_field_12 = 0.00; } else { merchant_defined_field_12 = parseFloat(document.fund.merchant_defined_field_12.value); } if(document.fund.merchant_defined_field_13.value == '') { merchant_defined_field_13 = 0.00; } else { merchant_defined_field_13 = parseFloat(document.fund.merchant_defined_field_13.value); } var total = merchant_defined_field_11 + merchant_defined_field_12 + merchant_defined_field_13; if(!parseFloat(total)) { document.fund.total.value = "Please enter a number"; } else { document.fund.total.value = total; } } </script> ANY HELP WOULD BE GREATLY APPRECIATED |
| ||
| Re: Help with making decimals show up always Use the method variablename.toFixed(2)in your statement placing the value in the field (Where 'variablename' is, put the name of your variable). |
| All times are GMT -4. The time now is 12:44 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC