I have everything working on my page http://demositepca.com/butch/calc.html
What i need to do is add a , in for the number so when i put in the first number and the second the rest of the number that are over 999 need to show up as 1,000 for example. I have tried to use some code that i found in my research but nothing yet.
Right now if i put in 35000 for the first text box and 25 for the second the first number i need to add a comma to is Direct Agency Customers text box and value will be 10010 but i need it to show up like 10,010.
Can anyone tell me how to do this for all the textboxes that are disabled.
function addCommas(nStr) {
if (!nStr) return;
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\\d+)(\\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
this.value = x1 + x2;
}
The issue with my code is that my numbers are generated by a caluculation and they are read only so onchange and onkeyup will now work in this process. I need a new way of running the code above to work and have it show the commas. I have also tried onblur and same thing.