|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
javascript addition
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 > In terms of interface design, its easier to auto-calc amounts, then youS. Isaac Dealey 07/23/02 02:22 P Very good point Isaac!.. .)John Ensign 07/23/02 04:42 P You might try adding a ParseInt() function around the value as well:Tim Painter 07/23/02 02:41 P JavaScript is case sensitive, so that should be parseInt() rather thanChris Lofback 07/23/02 02:56 P 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; } 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; } 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; } ----- 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 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 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 ----- 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 -----
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||