/    Sign up×
Community /Pin to ProfileBookmark

New to JavaScript, need to add…

Can someone give me instructions on how to do multiple subtotals that update themselves whenever a value on a [long] form is changed?

Thanks,
Zach

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JPnycJan 25.2006 — I think we'd need to see the form in question, but in general it would be something along these lines:

function subTotal() {

var frm = document.forms[0];

var subT=0;

for(var i = 0; i < frm.elements.length; i++) {

subT += parseFloat(frm.elements[i].value);



}}



Then call it onblur of each textbox, or however you'd like it to execute
Copy linkTweet thisAlerts:
@MissingDividendauthorJan 30.2006 — I mirrored the form here:

http://www.shepherdspecialties.com/mirror.php

I need to replace the "total" boxes with the actual total (not the thing in parenthesis (sp?) after it) of the boxes above it...

I probably should have mentioned that I know nothing about java script...

Can I use the same script for all of the sub totals and use different lablels somehow, or do I need to use a seperate script for each?
×

Success!

Help @MissingDividend spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...