Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add field values on a form

Status
Not open for further replies.

crimmelcp

Programmer
Oct 13, 2004
31
0
0
US
How do you add field values on a form

field1 + field2 = field 3

when I change field 1 or 2 then field 3 changes

Thanks
Charlie Crimmel
 
Patdundee,

Yes, as BRPS said.

If this can provide the quick fix to get the problem behind, I would be willing to do.
[tt] with (document.dean1) {
custotal.value=custotal.value.toFixed(2);
}[/tt]
(Same syntax can help you make the long reference to document.dean1 spared). This will round to 2 place. If you want truncate to 2 place, then can use Math.floor() like this.
[tt] with (document.dean1) {
custotal.value=Math.floor(custotal.value*100)/100);
}[/tt]
If still have doubt, open a new thread and I am sure members would help.

regards - tsuji
 
No matter how I process the code it always comes out the same as you see it.

I did not ask you to "process" the code - simply to insert some spaces in it when you post it. I didn't think I could have said it any clearer that I did ("When you do ask the new question, can you ... put some spaces in").

It will aid formatting, and readability, but will not change the syntax or output of the code, if, when you repost your code, you put some spaces in at pertinent locations. Ideally, these would be around operators, such as * and +. For example, you might replace "xx+xx" with "xx + xx". This will allow the code to wrap more effectively.

Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Thanks guys will pass this as a new post as you suggest. I have tried the methods above but it is rounding the decimal part of the equation to an integer ie 4.843542 is now returning as 5
Maths I can do Maths and VBscript etc I can do BUT Maths and java! thats a whole new ball game lol
 

Java and Javascript are a whole different ball game.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
>I have tried the methods above but it is rounding the decimal part of the equation to an integer ie 4.843542 is now returning as 5

???... You must not have read carefully!
[tt] alert((4.843542).toFixed(2));
alert(Math.floor(4.843542*100)/100);[/tt]
I wonder what else can you get!

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top