OZONE Asylum
Forums
DHTML/Javascript
JS Function & Variable Storage
This page's ID:
27926
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Thanks for the help. I switched it up by using the button instead. I tried your example, but sometimes you would have to click twice for it to work. Here is my new code, only thing I want to change is so "enter" key works to execute the function : [code] <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <title>TME 2 Part 4</title> <script language="Javascript" type="text/javascript"> var current_charges=0; var running_total=0; var hours; var hoursparked; function calculateCharges(hours) { if ( hours <= 3 ) { current_charges = 2; } else if ( hours > 3 && hours <= 19) { current_charges = 2 + (0.50 * (hours - 3)); } else { current_charges = 10; } document.parking.current.value="$" + current_charges; running_total=running_total + current_charges; document.parking.running.value="$" + running_total; } </script> </head> <body> <form name="parking" onSubmit="return false;"> Please enter the number of hours parked for the current customer: <br> <input type="text" name="hoursparked" value=""> <br> <input type="button" onClick="calculateCharges(document.parking.hoursparked.value);" value="Calculate"> <p> Charges for current customer: <input type="text" name="current" value=""> <p> Yesterday's running total: <input type="text" name="running" value=""> </form> </body> </html> [/code]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »