•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 363,508 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,423 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 483 | Replies: 1
![]() |
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Collins: Why this scientist believes in God (Geeks' Lounge)
- Please review my website!! (Website Reviews)
- "Active" files and moving/changing paths (C++)
- CSS browser compatibility ??? (HTML and CSS)
- would like to know how to make animated pictures (IT Technologies and Trends)
- case study help please (Networking Hardware Configuration)
- Quicktime and MPEG4 (Java)
- IE security not showing rollovers, "ActiveX blocked" on my page... (HTML and CSS)
- need info? can't use strcmp/string compare (C++)
- buying new monitor (Monitors, Displays and Video Cards)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Links to Rotating Banner Ad
- Next Thread: Dynamic iFrame height, not working in ie without refresh.



Linear Mode