-
Dec 25th, 2012, 12:25 AM
#1
Thread Starter
Fanatic Member
get minutes from selected hours
i have following code for users to select hours.
its only for 1 to 12 hours format
all fields are dropdown
startHour : startMinutes : finishHour : finishMinutes : AM/PM
i want to validate with javascript that user can only select correct time. And calculate the minutes of selected hours from dropdown menus.
example
2:00 To 6:00 PM
3:15 To 4:45 PM
11:00(AM) To 2:00 PM
here is the code for my html
Code:
<table border="1" cellpadding="5" cellspacing="0" align="center">
<tr>
<td>Start Time</td>
<td>Finish Time</td>
<td>AM/PM</td>
<td> </td>
</tr>
<tr>
<td>
<select id="cbo_start_hour" name="cbo_start_hour">
<option value="-1">Hour</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select id="cbo_start_minute" name="cbo_start_minute">
<option value="-1">Minute</option>
<option>00</option>
<option>15</option>
<option>30</option>
<option>45</option>
</select>
</td>
<td>
<select id="cbo_finish_hour" name="cbo_finish_hour">
<option value="-1">Hour</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select id="cbo_finish_minute" name="cbo_finish_minute">
<option value="-1">Minute</option>
<option>00</option>
<option>15</option>
<option>30</option>
<option>45</option>
</select>
</td>
<td>
<select id="cbo_am_pm" name="cbo_am_pm">
<option value="-1">AM/PM</option>
<option>AM</option>
<option>PM</option>
</select>
</td>
<td>
<input type="button" value="Start Time" onClick="start_time()" class="btn_submit">
</td>
</tr>
</table>
Last edited by chunk; Dec 25th, 2012 at 01:37 AM.
-
Jan 2nd, 2013, 01:56 PM
#2
Frenzied Member
Re: get minutes from selected hours
Convert your date representation to Javascript Date object instances and perform validation using those. Subtract the two date instances to get the delta amount of milliseconds between the two.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|