Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sliding scale calculator

Status
Not open for further replies.

tyutghf

Technical User
Apr 12, 2008
258
0
0
GB
Hi folks, I have been asked to make a commission calculator for a new department.

Basically, the calculations are thus

sell 0 - 10k = 0% commission
10k - 25k = 10% commission
25k - 35k = 15% commission
35k - 50k = 25% commission
50k+ = 35% commission

This calculator has to be on our website so people can see the potential they can earn by entering a figure they expect to sell in the box. Don't laugh at my attempt so far

Code:
<script type="text/javascript">

function commissionCalc(){
[indent]var enteredSales = document.getElementById("sales").value;

if (enteredSales < '10000') {
[indent]var earnings = enteredSales[/indent]
} else if (enteredSales > 10000 && enteredSales < 25000) {
[indent]var earnings = enteredSales = (enteredSales * 0.1)[/indent]

[/indent]
}

</script>

<form>
<input type='text' name='sales' />
<input type='text' name='commissionresult' />
</form>

Am I on the right track? I don't want to spend ages on it to find I've been doing it wrong, I haven't been given much time on it.
 
Using a switch statement is a better method.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top