[Javascript] doing totals of form values client side - examples

Jason Belanger BELANGERJ at EM.AGR.CA
Tue Aug 21 12:19:09 CDT 2001


Peter, thanks for your help. I did a bit of work on my own and came up with this using an OnChange and pull down menus:

function maketotal() {
var itemA=document.bulb.A.value * 25;
var itemB=document.bulb.B.value * 8;
var itemC=document.bulb.C.value * 8;

var totalcost= itemA + itemB +itemC
document.bulb.TOTAL.value=totalcost; 
}

How would I use a loop in a case like this?
For each item in document.bulb ??
//do stuff
Next

If I am setting the values, do I "need" to use the ParseInt and ParseFloat? What kinds of things happen when I don't use them?

TIA

Jason


Jason Belanger
Web Technologies System Specialist
(613) 759-7809
belangerj at em.agr.ca
http://www.agr.ca/

>>> "Peter Brunone" <peter at brunone.com> 08/21/01 12:09PM >>>
Jason,

    If you want to update in real time, just slap an onChange event handler
on all changeable text fields.  Remember to parseInt() or parseFloat() the
form field value since it starts as a string; not much more to it.  It's
even simpler for checkbox values, as you can see at
http://www.digitaltechnologyconsulting.com/orderform.asp .

Cheers,

Peter

----- Original Message -----
From: "Jason Belanger" <BELANGERJ at EM.AGR.CA>
To: <javascript at LaTech.edu>
Sent: Tuesday, August 21, 2001 10:14 AM
Subject: [Javascript] doing totals of form values client side - examples


Does anyone have any examples or URLs on making running totals for purchase
webpage using Javascript?

Jason

Jason Belanger
Web Technologies System Specialist
(613) 759-7809
belangerj at em.agr.ca 
http://www.agr.ca/ 

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu 
http://www.LaTech.edu/mailman/listinfo/javascript 


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu 
http://www.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list