/    Sign up×
Community /Pin to ProfileBookmark

How do I display totals of form fields on page

Hi,

I’ve just started writing JavaScript so this is a newbie question. I have a form where user enters a bunch of numbers i.e. shipping charge, sales tax, etc.

I want to total them up and display them at the bottom of the form. I know how to add them up but what I need help with is displaying the total. I don’t want to display the total in an input box which seems to be a common way to do this. I’d rather display it on the page at a specific location. How do I do this? In other words, how do I specify where to display my total? I assume I’ll be using document.write(MyTotal) but not sure how to specify its location.

Thanks for your help.

Sam

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KDLAAug 07.2009 — Instead of placing the total in a form field, you can place it in a div with an ID, using innerHTML: http://www.tizag.com/javascriptT/javascript-innerHTML.php

It would require, however, a button clicked to update the HTML.

However, using CSS, you can style a form field to look like part of the page. That's how many developers accomplish this.
Copy linkTweet thisAlerts:
@imsamauthorAug 07.2009 — Thanks very much KDLA! I really appreciate your help.

Sam
×

Success!

Help @imsam 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.18,
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,
)...