House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

javascript addition

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hello,
Tim Do
07/23/02 12:41 P
Use the function eval() with each textbox value:
Matthew R. Small
07/23/02 12:50 P
IMHO...
John Ensign
07/23/02 01:08 P
Very good point Isaac!.. .)
John Ensign
07/23/02 04:42 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tim Do
07/23/2002 12:41 PM

Hello, Can anybody show me how you would I would validate the sum of several text boxes?  This is what I'm trying to use but not having luck.. thanks in advance. function validate() { if (document.newBillingInfo.SCEPbilledAmount.value + document.newBillingInfo.SCEPpenaltyAmount.value + document.newBillingInfo.SCEPdelinquentAmount.value != document.newBillingInfo.SCEPtotalAmount.value)   {     alert("The total Billing amount does not add up correctly, Please check the values.")     document.newBillingInfo.SCEPbilledAmount.focus()     return false;   }        return true;    }

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matthew R. Small
07/23/2002 12:50 PM

Use the function eval() with each textbox value: Eval(document.newBillingInfo.SCEPbilledAmount.value) - Matt Small Hello, Can anybody show me how you would I would validate the sum of several text boxes?  This is what I'm trying to use but not having luck.. thanks in advance. function validate() { if (document.newBillingInfo.SCEPbilledAmount.value + document.newBillingInfo.SCEPpenaltyAmount.value + document.newBillingInfo.SCEPdelinquentAmount.value != document.newBillingInfo.SCEPtotalAmount.value)   {     alert("The total Billing amount does not add up correctly, Please check the values.")     document.newBillingInfo.SCEPbilledAmount.focus()     return false;   }        return true;    }

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
John Ensign
07/23/2002 01:08 PM

IMHO... In terms of interface design, its easier to auto-calc amounts, then you kind of take out the human element... And if youre involving 10 fields for some kind of calculation, and the value "they" enter is wrong, how do you point to the incorrect amount in the appropriate field? (assuming youve already set limits, and checked to make sure the values, if numeric, are within that range). Its simpler to auto calc it for them.  Although, you should also recheck the math on the server by re-calculating the field amounts again, just to be sure. ) hope any of this helps, John Ensign Hello, Can anybody show me how you would I would validate the sum of several text boxes?  This is what I'm trying to use but not having luck.. thanks in advance. function validate() { if (document.newBillingInfo.SCEPbilledAmount.value + document.newBillingInfo.SCEPpenaltyAmount.value + document.newBillingInfo.SCEPdelinquentAmount.value != document.newBillingInfo.SCEPtotalAmount.value)   {     alert("The total Billing amount does not add up correctly, Please check the values.")     document.newBillingInfo.SCEPbilledAmount.focus()     return false;   }   return true; }

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
S. Isaac Dealey
07/23/2002 02:22 PM

----- Excess quoted text cut - see Original Post for more ----- Hey John, most of the time I agree with you... that is, when you're just summing up values that a user has given you and getting whatever total they produce, i.e. for a mortgage app where the user enters their financial info and all you want to know is their total annual income for their application. The exception is when the user is entering values which must add up to a given total which is required by some other external mechanism, i.e. in a grade-weighting schedule for an electronic report-card where grades for different types of assignments may be weighted differently, but the sum of all wieghts must add up to 100 ( making each point in the weighting schedule exactly 1% ). In order to calculate the percentage, you have to know the total points, so if you want to double-check the teachers to make sure their math adds up, you can enforce a 100pt total and you know that if their numbers don't add up to exactly 100 they need to check their math and make an adjustment. I _think_ he may be doing something similar to this, although I'm not certain of that... Isaac Dealey www.turnkey.to 954-776-0046

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
John Ensign
07/23/2002 04:42 PM

Very good point Isaac!..   .) ---- John ----- Excess quoted text cut - see Original Post for more ----- Hey John, most of the time I agree with you... that is, when you're just summing up values that a user has given you and getting whatever total they produce, i.e. for a mortgage app where the user enters their financial info and all you want to know is their total annual income for their application. The exception is when the user is entering values which must add up to a given total which is required by some other external mechanism, i.e. in a grade-weighting schedule for an electronic report-card where grades for different types of assignments may be weighted differently, but the sum of all wieghts must add up to 100 ( making each point in the weighting schedule exactly 1% ). In order to calculate the percentage, you have to know the total points, so if you want to double-check the teachers to make sure their math adds up, you can enforce a 100pt total and you know that if their numbers don't add up to exactly 100 they need to check their math and make an adjustment. I _think_ he may be doing something similar to this, although I'm not certain of that... Isaac Dealey www.turnkey.to 954-776-0046

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tim Painter
07/23/2002 02:41 PM

You might try adding a ParseInt() function around the value as well: e.g. ParseInt(document.newBillingInfo.SCEPbilledAmount.value) + ParseInt(document.newBillingInfo.SCEPpenaltyAmount.value) etc... Tim P. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chris Lofback
07/23/2002 02:56 PM

JavaScript is case sensitive, so that should be parseInt() rather than ParseInt(). Chris Lofback Sr. Web Developer TRX Integration 28051 US 19 N., Ste. C Clearwater, FL  33761 www.trxi.com You might try adding a ParseInt() function around the value as well: e.g. ParseInt(document.newBillingInfo.SCEPbilledAmount.value) + ParseInt(document.newBillingInfo.SCEPpenaltyAmount.value) etc... Tim P. ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

March 20, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31