| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Member | hello can anyone point me in the right direction? searched google but no luck what i need: a profit calculator to: Ex: people can calculate their profit for selling stuff. Number of people: 20 Number of dvds: 10 Number of books: 10 Total profit 12000$ now here is the math: when they add 10 dvds this will be multiplied with 32$ when they add 10 books it will be multiplied with 28$ so 32*10=320$+280$(10*28)=600$ * 20people=12000$ Can someone tell me?thanks |
| |
| | #4 (permalink) |
| NamePros Member | Code: <html>
<head>
<script type='text/javascript'>
function calc() {
var cost_dvd = 32;
var cost_book = 28;
document.getElementById('total').innerHTML = Math.floor(document.getElementById('people').value) * (Math.floor(document.getElementById('dvds').value) * cost_dvd + Math.floor(document.getElementById('books').value) * cost_book);
}
</script>
</html>
<body>
People: <input type='text' size='3' id='people' onkeyup='calc();' value='0' /><br />
DVDs: <input type='text' size='3' id='dvds' onkeyup='calc();' value='0' /><br />
Books: <input type='text' size='3' id='books' onkeyup='calc();' value='0' /><br /><br />
Total: $<span id='total'>0</span>
</body>
</html>
Bruce |
| |
| | #6 (permalink) |
| Senior Member | take out the onkeyup="calc();" from the 3 <input>s and add an <button onclick="calc();> and you SHOULD get the same result, except on button click.
__________________ Hacksar.com - Your source for random computer tips and tricks! MySiteMemberships.com - Keep track of your site registration information! Like my post? Rep is appreciated! |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |