Combining two javascript functions to calculate form
<p>I have a form that calculates the time between two dates, and stores 6 numeric fields.</p>

<p>I wnat to be ale to have the form claculate these values as the user starts selecting after the two dates so that the form works as intended.</p>

<p>A sample page is located here..of what my intentions are</p>

<p><a href="http://jsfiddle.net/GfN5u/1/" rel="nofollow">http://jsfiddle.net/GfN5u/1/</a> the js is withing the html</p>

<p>I feel i'm almost there but lifes not fair to me this week.</p>

<p>Also in IE 8 the select elements lose their content.....even in jsfiddle.</p>

<p>Any help would be appreciated.</p>

<p>Thank you</p>

<pre><code>        &lt;script&gt;
        var txt1 = document.Edit.StartTime.value
        var txt2 = document.Edit.EndTime.value

        var differenceInSeconds = (Calendar.parseDate(txt2, false).getTime() - Calendar.parseDate(txt1, false).getTime())/1000;
        var val9 = differenceInSeconds/60.0/60
        alert(val9)
        &lt;/script&gt;


            &lt;script&gt;
        re=/\D/g

        function getGoodVal(fld) {
        var val = fld.value;
        if (!val) val=0;
        if (isNaN(val)) {
        val=val.replace(re,""); // remove all nonDigits
        }
        if (val=="" || isNaN(val)) val = 0; // still not a number or empty
        val = parseFloat(val)
        fld.value=val.toFixed(2);
        return val;
        }

        function calc(theForm) {
        var val10 = val9
        var valb = getGoodVal(theForm.lunch);   
        var val1 = getGoodVal(theForm.TRDO);
        var val2 = getGoodVal(theForm.AnnualLeave);
        var val3 = getGoodVal(theForm.PersonalLeave);
        var val4 = getGoodVal(theForm.WorkFromHome);
        var val5 = getGoodVal(theForm.TOIL); 

        total = (val9-valb) + (val1+val2+val3+val4+val5);
        theForm.total.value=total.toFixed(2)
        }
        &lt;/script&gt;   
</code></pre>
