novas
Posts: 1
|
Posted: 01/11/2014, 7:32 AM |
|
i tried using the javascript in the order entry example from the example pack on my editable grid, the (the show_total() function is working but the "Total_price" below in the {Total_price} text field did not to display the sum of the SumPrice
but first let me show the script error that occurred on the page
document.priscription_claims.Total_price
let me show the javascript code
function StrToFloat(str)
{
if (str.indexOf(",") != -1) {
str = str.replace(",",".");
}
var result = parseFloat(str);
if (isNaN(result)) {
result = 0.0;
}
return result;
}
function Show_Total()
{
var TotalSum=0;
var Summ;
for(var i = 0; i < priscription_claimsElements.length; i++){
Summ = StrToFloat(priscription_claimsElements[priscription_claimspriceID].value) *
StrToFloat(priscription_claimsElements[priscription_claimsquantityID].value);
TotalSum = TotalSum + Summ;
if (Summ == 0) {
priscription_claimsElements[priscription_claimsSumPriceID].value = "";
} else {
priscription_claimsElements[priscription_claimsSumPriceID].value = Math.round(Summ*100)/100;
}
}
document.priscription_claims.Total_price.value = Math.round(TotalSum*100)/100;
}
|
|
|
eratech
Posts: 513
|
Posted: 01/12/2014, 4:29 PM |
|
Hi novas - my first step with debugging any JS is to open your browser's web development tools (or Firebug extension) and find the JS source, and step through the code (set some breakpoints, and then check the values as the code is run). If you haven't used them before, I strongly suggest googling up "firebug" and "developer tools chrome" (or safari, or firefox, or IE etc) as they will help a lot in javascript testing.
The usual problem with these errors is that the JS cannot find the ID or name of the textbox to update. Check the names in the code match exactly the names in the HTML/textboxes, including capitalisation.
Cheers
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
|