Help - Search - Members - Calendar
Full Version: javascript auto calcuate value based on user input
HTMLHelp Forums > Programming > Client-side Scripting
potato_chip
Hey, I need some help here on javascript functions:

here is what I want to do. I want user to enter the start time and end time, once both fields are entered, the total work hours field will be calculated and showed automatically.

below is my simple html code:
CODE

<table border="1" cellspacing="0" cellpadding="2">
<tr><td>Start Time</td><td>End Time</td><td>Hours</td></tr>
  <tr>
      <td><input type="text" name="startTime" /></td>
    <td><input type="text" name="endTime" /></td>
    <td><input name="text" disabled="disabled"/></td>    
  </tr>
</table>


I'm really new to Javascript. Any help is greatly appreciated!
Darin McGrew
I'm not very experienced with JavaScript either, but I suggest that you break down the problem into small steps and figure out how to do each in turn:
  1. display the start time
  2. display the end time
  3. display just the hours of the start and end time
  4. display just the minutes of the start and end time
  5. determine whether the start time is before the end time, and display an appropriate message
  6. etc.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.