| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Apr 2008
Posts: 104
![]() | |
| |
| | #4 (permalink) |
| NamePros Member Join Date: Sep 2006
Posts: 99
![]() ![]() | 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> ????: NamePros.com http://www.namepros.com/programming/493467-profit-calculator.html Bruce |
| |
| | THREAD STARTER #5 (permalink) | ||||
| NamePros Member Join Date: Apr 2008
Posts: 104
![]() |
| ||||
| |
| | #6 (permalink) |
| Senior Member Join Date: Jul 2005 Location: NJ
Posts: 1,219
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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! |
| |
| | THREAD STARTER #7 (permalink) | ||||
| NamePros Member Join Date: Apr 2008
Posts: 104
![]() |
| ||||
| |