/    Sign up×
Community /Pin to ProfileBookmark

Auto Calculation

Hi I am working on a page and I would like for certain field to auto calculate do u have any suggestion as to how I can do that?

P

to post a comment
JavaScript

14 Comments(s)

Copy linkTweet thisAlerts:
@buntineSep 29.2004 — Sure, but you may want to give us some more details. We dont know what you want to calculate!

Regards.
Copy linkTweet thisAlerts:
@icebabyauthorSep 29.2004 — ok let me attach the page and explain what I need.. This is the page http://www.airturksandcaicos.com/test.htm

The adult fare is $120 and the child fare is $90 I would like when u select 2 adults it auto calculates $240 in to Total Adult fare box and same for the child.

Then the total adults and total children coloumn to auto calculate and give the total fares..

Can that be done? Or if u have a easier way let me know..

Thanks
Copy linkTweet thisAlerts:
@Khalid_AliSep 29.2004 — It seems like its a JavaScript question....I am moving this thread to JavaScript forum.
Copy linkTweet thisAlerts:
@icebabyauthorSep 29.2004 — some one help me please I realy need this...

Thanks
Copy linkTweet thisAlerts:
@icebabyauthorSep 29.2004 — does any one have any ideas how I can work around this?
Copy linkTweet thisAlerts:
@mercury7Sep 29.2004 — Go to http://vivxdesign.com/template/tickets.htm . There you'll see a different implementation of what you're talking about. I think it's a better one though. I didn't complete the program for you; you'll still need to add the calendar functionality to it, but it should get you more than started. Go view>source to see how I did it.
Copy linkTweet thisAlerts:
@icebabyauthorSep 29.2004 — ok mercury thanks i will check it out.
Copy linkTweet thisAlerts:
@mercury7Sep 29.2004 — You're welcome. Let me know if that is what you were looking for. I'm feeling charitable today.
Copy linkTweet thisAlerts:
@icebabyauthorSep 29.2004 — thanks for feeling charitable.. I have one other question if u want another set of addition on that same page what do u have to do..
Copy linkTweet thisAlerts:
@icebabyauthorSep 29.2004 — what about doing percentage?
Copy linkTweet thisAlerts:
@mercury7Sep 30.2004 — Here's a new function with tax functionality. You need to change the id and name of your form element, "Fuel Charge", to "fuelCharge". JavaScript uses one-word names. If you have any other fees, then just add more lines of script and add them to the total.

[code=php]
</style>
<script type="text/javascript">
var total=0;
var tax=.10; //Set tax amount 10% = .10
var taxAmount;
function addTotal(type, number){
if (number!="How many travelling?"){
number=parseInt(number);
if (type==1) total=total+(120*number);
else if (type==2) total=total+(90*number);
else alert("something wrong!");
taxAmount=total*tax; //calculate tax
document.form1.fuelCharge.value=taxAmount; //report
total=taxAmount+total; //add tax to total
document.form1.totalcost.value=total; //report total
}
else {alert("Please enter a valid nuber of tickets!nThen, selcet your ticket type.");}
}
</script>
[/code]
Copy linkTweet thisAlerts:
@icebabyauthorSep 30.2004 — I put in the code and the page is not working..
Copy linkTweet thisAlerts:
@mercury7Sep 30.2004 — Do you understand the code?

I told you in the other post that you have to change the name of one of your textboxes. I also did not add the code for a fixed fee. I thought you could handle that. If you want a fixed fee, then just add whatever the amount is to the total
×

Success!

Help @icebaby 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...