PDA

View Full Version : Adding in JS



Ventu
09 Jan 2008, 09:16 AM
Hello everyone,

I have a question on addition in JS. First off, I work for an independant agent under AT&T. My boss owns five stores that fax over cashsheets everyday. My boss then asked me to make an online cashsheet, to email to him the cashsheets, which I did. Then he asked if I could have the amounts total which i did....kinda. This is my JS (http://totalcom.us/new/add.js) . I'm a novice at this stuff but I think i have it placed right.

Everything has worked up to a point though. What i have setup is this:

Total Drawer Start Drawer Bag Money

$.01 Money money blah blah
$.05
$.10
$.25
$1
$5
$10
$20
$50
$100

Ok, thats how I ahve it setup not including the check amounts or the creidt card amounts but thats all working. What isn't working is that if I place( within any of the cents sections) more than .99 as in .99 cents in change. it give me amount that have 10 decimal places. For example: 3.30 in dimes messed it up, but .30 didn't.

At first, as you can see that i have parseFloat on each one of the formulas, I didn't have parseInt wish didn't allow me to calculate decimals.

So hopefully I have given enough to get some help on this.

Thanx a lot guys

P.S. If there is a way, is it posible to have these amount total automatically in the Totals boxes, instead of me clicking a button.

Ventu
12 Jan 2008, 09:17 AM
Hello everyone,

I have a question on addition in JS. First off, I work for an independant agent under AT&T. My boss owns five stores that fax over cashsheets everyday. My boss then asked me to make an online cashsheet, to email to him the cashsheets, which I did. Then he asked if I could have the amounts total which i did....kinda. This is my JS (http://totalcom.us/new/add.js) . I'm a novice at this stuff but I think i have it placed right.

Everything has worked up to a point though. What i have setup is this:

Total Drawer Start Drawer Bag Money

$.01 Money money blah blah
$.05
$.10
$.25
$1
$5
$10
$20
$50
$100

Ok, thats how I ahve it setup not including the check amounts or the creidt card amounts but thats all working. What isn't working is that if I place( within any of the cents sections) more than .99 as in .99 cents in change. it give me amount that have 10 decimal places. For example: 3.30 in dimes messed it up, but .30 didn't.

At first, as you can see that i have parseFloat on each one of the formulas, I didn't have parseInt wish didn't allow me to calculate decimals.

So hopefully I have given enough to get some help on this.

Thanx a lot guys

P.S. If there is a way, is it posible to have these amount total automatically in the Totals boxes, instead of me clicking a button.

alirght I guess I didn't explain myself good enough :P. Thats ok I have an image.
http://www.totalcom.us/new/images/cashsheet.jpg

If I were to change the $.01 to 1, to signify 1 dollar in pennies it would give me 2 decimal places. Also if i gave Dimes a 1 dollar amount it would go bac kto normal also.