I have a form which calculates hours and mins between to times. I would like to convert result to value for calculating like 1hour 30 mins is result 1,5. Now I am getting result 1,3. I need to calculate at the moment and write it.
I found some converters but it doesnt calculate at the moment so it is not good for what I need.
I also want to user see hours and mins like my code shows. I know I could only split seconds with 0,6 but then show in select option 0,25 instead 0,15. Thats not an option.
- Ura pričetka - start time,
- Ura končanja - end time,
- Nadure - it is just calculating the value over a certain value,
- Ure - result which have to be calculated and converted at the moment
I am calculating in java.
Code:
<td align="left">Ure </td>
<td align="left"><input name="ure" id="ure" type="text" onchange="updatesum()"/></td>
</tr>
<tr>
<th align="right">Ura pričetka </th>
<td align="left"><select name="urap" id="urap" type= "time" onChange="updatesum()" value="9.00"/>
<OPTION>
<?php for($hours=0; $hours<24; $hours++) // the interval for hours is '1'
for($mins=0; $mins<60; $mins+=15) // the interval for mins is '15'
echo '<option>'.str_pad($hours,2,'0',STR_PAD_LEFT).'.'
.str_pad($mins,2,'0',STR_PAD_LEFT).'
</option>'; ?></OPTION></td>
<td align="left">Nadure </td>
<td align="left"><input name="nadure" id="nadure" type="text" onchange="updatesum()" /></td>
</tr>
<tr>
<th align="right">Ura končanja </th>
<td align="left"><select name="urak" id="urak" type= "time" onChange="updatesum()" value=""/>
<OPTION>
<?php for($hours=0; $hours<24; $hours++) // the interval for hours is '1'
for($mins=0; $mins<60; $mins+=15)
// the interval for mins is '15'
echo '<option>'.str_pad($hours,2,'0',STR_PAD_LEFT).'.'
.str_pad($mins ,2,'0',STR_PAD_RIGHT).'
</option>';
?>
</OPTION>
</td>
<script type="text/javascript">
function updatesum() {
document.loginForm.ures.value = (document.loginForm.urak.value -0) - (document.loginForm.urap.value -0);
$ures = loginForm.ures.value;
if (loginForm.ures.value > <?php echo $test ?>) {
loginForm.ure.value ='<?php echo $test ?>'
loginForm.nadure.value = (document.loginForm.ures.value -0) - (document.loginForm.ure.value -0);
}
if (loginForm.ures.value <= <?php echo $test ?>) {
loginForm.ure.value = loginForm.ures.value
loginForm.nadure.value = (document.loginForm.ures.value -0) - (document.loginForm.ure.value -0);
}
};
</script>
<input type="text" name="ures" onChange="updatesum()"/>