There is a function that calculates and displays the difference of 2 time variables the user selects in separate drop down lists. The display is invoked when the paragraph tags are used in the form. Function below:
<script type='text/javascript'>//<![CDATA[
$(window).load(function () {
$(document).ready(function () {
function calculateTime() {
//get values
var valuestart = $("select[name='timestart']").val();
var valuestop = $("select[name='timestop']").val();
//create date format
var timeStart = new Date("01/01/2007 " + valuestart).getHours();
var timeEnd = new Date("01/01/2007 " + valuestop).getHours();
var hourDiff = timeEnd - timeStart;
$('p').html("Total Hours: " + hourDiff)
}
$("select").change(calculateTime);
calculateTime();
});
});//]]>
</script>
The function works. However, I'm needing the "difference in time" value to be passed to an HTML input tag and displayed instead of simply being displayed when paragraph tags are used.
Is there be a way to do this?