Thread: How do I calculate a percentage off of a certain input value?

1. How do I calculate a percentage off of a certain input value?

So I'm in an intro to web development class and our assignment is to create a form that calculates fees for a charter boat company. I have the basic form, however, I can't seem to figure out how to take a percentage off of an input value. In example, I want to take 10% off of the total fee if a customer books more than 8 hours. Here is the website to our assignment if needed: http://is1500.weebly.com/assignment-7.html

<div>Number of Hours: <input type="text" id="hours"><br/>
Number of Guests: <input type="text" id="guests"><br/>
Docking at Oak Bluffs? <input type="checkbox" id="docking"></br>
Need Fishing Gear? <input type="checkbox" id="fishing">
<p>
<button onClick="calculate()">Calculate Fee</button>
<p>
Based on your input, your charter fee is going to be<span id="fee">...</span>

<script>
function calculate()
{
var fee = document.getElementById("hours").value;
var guests = document.getElementById("guests").value;
var dock = document.getElementById("docking").checked;
var dockingFee;
var fishing = document.getElementById("fishing").checked;
var fishingFee;

if (dock == true)
dockingFee = 20;
else
dockingFee = 0;

if (fishing == true)
fishingFee = 50;
else
fishingFee = 0;

document.getElementById("fee").innerHTML = "\$" + ((fee * 275) + (guests * 15) + (fishingFee + dockingFee));
}
</script></div>

</div>

2. pleeeease help my head hurts from trying so many different times... I figure >8 would be understood i just don't understand how to write it out to relate to var fee

3. changed "fee" to "hourly"

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•