我有一个html页面,需要存储按钮点击数据库时的时间。我有一个计算时间的JS函数。但不知怎么的,html按钮没有保存这个值。这里是代码。如何将一个JS函数的输出返回到一个HTML按钮'id'
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
function checkMsec(j)
{
if ((j<100) && (j<10))
{
j="00" + j;
}
if ((j<100) && (j>10))
{
j="0" + j;
}
return j;
}
function timeCheck(stTime)
{
var currentTime=new Date();
var cDat = currentTime.getDate();
var cMon = currentTime.getMonth() + 1;
var cYear = currentTime.getFullYear();
var h = currentTime.getHours();
var m = currentTime.getMinutes();
var s = currentTime.getSeconds();
var ms = currentTime.getMilliseconds();
m = checkTime(m);
s = checkTime(s);
ms = checkTime(ms);
stTime = cDat+"-"+cMon+"-"+cYear+" "+h+":"+m+":"+s+":"+ms;
//alert(stTime); // this is displaying the time as an alert
return stTime; //Here I am expecting the id attribute of the button will have the stTime
}
Time 1:
Time 2: