ผมมีแต่การหาผลต่างคัวเลขธรรมาดางะ
ถ้าต้องการเป็นแบบเวลางะทำไงงะ
<script>
function doUpdate(){
var t1=document.form1.a1.value*1;
var t2=document.form1.a2.value*1;
document.form1.a3.value=t1-t2;
}
</script>
function datedifference()
{
var strDate1 = document.FrmName.DateStart.value
var strDate2 = document.FrmName.DateEnd.value
var bldatediff = false
//Start date split to UK date format and add 31 days for maximum datediff
strDate1 = strDate1.split("/");
starttime = new Date(strDate1[2],strDate1[1]-1,strDate1[0]);
starttime = new Date(starttime.valueOf()+31*86400000);
//End date split to UK date format
strDate2 = strDate2.split("/");
endtime = new Date(strDate2[2],strDate2[1]-1,strDate2[0]);
endtime = new Date(endtime.valueOf());
if(endtime > starttime)
{
bldatediff = true
}
return bldatediff
}
------------------------------------------------------
function submit()
//This will go into the submit button function.
bldatediff = datedifference()
// Takes the date from the Start date and adds
// 31 days to make it the maximum end date
strDate1 = strDate1.split("/");
starttime = new Date(strDate1[2],strDate1[1]-1,strDate1[0]);
starttime = new Date(starttime.valueOf()+31*86400000);
starttime = padDigit(starttime.getDate())+"/"+padDigit(starttime.getMonth()+1)+"/"+starttime.getYear();
// if bldatediff = true than the end date is later than 31 days.
if (bldatediff==true)
{
alert("Please pick an End Date before:\n\n" + starttime)
}
else
{
if (blSubmit==true)
{frmSearchFlds.submit();}
}