/    Sign up×
Community /Pin to ProfileBookmark

Help with forms

I have a customer that wants a estimate calulator on there site. They have certain types of services that they offer and they want when they click on one of there services to add it to a box. There site is an on site company so they want it to also add up miles with a certain price per mile. So the customer would add how many miles it was from there store to there house the first 20 miles are free. So it would take the difference and then add the dollar amount for the miles. Then give a grand total for the service and miles. Anyone know of a website that has it that I can download? Or any ideas on how to write it in javascript. Any help with this would be great. Thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ExuroJun 02.2004 — I'm assuming you have no knowledge of JavaScript do you? Here's a general idea of what you might use:

[code=php]
var totalMiles; // You would need to get this value from the user
var PRICE_PER_MILE; // This would be a constant?
var estimatedCost = 0; // Should be initalized to 0
if (totalMiles > 20) { // If the distance is more than 20 miles
estimatedCost = (totalMiles - 20) * PRICE_PER_MILE; // Calculate the estimate
}
document.write(estimatedCost) // Write out the cost
[/code]
×

Success!

Help @cstickman 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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