S
staeri
I'm looping through some textboxes to sum the values. If the value in
the textbox has a dot or a space as thousand separator the sum function
doesn't work.
Can someone help me to make it work also with thousand separators?
function UpdateBudget(callingcontrol, totalcontrol)
{
var amount = 0
var f = document.forms['form1'];
if (f) {
f = f.elements;
}
var i = f.length;
var disp = ""
while (i-- > 0) {
if (f.type == 'text') {
if (f.name.indexOf("Budget") >= 0) {
if (f.name.substr(0,16) ==
callingcontrol.name.substr(0,16)) {
var n = parseInt(f.value, 10);
if (isNaN(n)) {
amount += 0;
}
else {
amount += n;
}
}
}
}
}
SumBudget(callingcontrol, amount)
}
Grateful for help!
Regards,
S
the textbox has a dot or a space as thousand separator the sum function
doesn't work.
Can someone help me to make it work also with thousand separators?
function UpdateBudget(callingcontrol, totalcontrol)
{
var amount = 0
var f = document.forms['form1'];
if (f) {
f = f.elements;
}
var i = f.length;
var disp = ""
while (i-- > 0) {
if (f.type == 'text') {
if (f.name.indexOf("Budget") >= 0) {
if (f.name.substr(0,16) ==
callingcontrol.name.substr(0,16)) {
var n = parseInt(f.value, 10);
if (isNaN(n)) {
amount += 0;
}
else {
amount += n;
}
}
}
}
}
SumBudget(callingcontrol, amount)
}
Grateful for help!
Regards,
S