|
藍森林 http://www.lslnet.com 2006年8月25日 8:28
系統時間填入到文本框
那位朋友可以把系統時間填入到文本框,格式是2005-05-09,而不是2005-9-1。 |
[html]
<!--把以下代碼copy至你的html文件的<body>和</body>之間-->
<script>
<!-- Hide
var timerID = null
var timerRunning = false
function MakeArray(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
{
this[i] = "";
}
return this;
}
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
}
function showtime () {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var day = now.getDay();
Day = new MakeArray(7);
Day[0]="SUN";
Day[1]="MON";
Day[2]="TUE";
Day[3]="WED";
Day[4]="THU";
Day[5]="FRI";
Day[6]="SAT";
var timeValue = "";
timeValue += (Day[day]) + " ";
timeValue += ((month < 10) ? " 0" : " ") + month + "-";
timeValue += date + "-" + year + " ";
timeValue += ((hours <= 12) ? hours : hours - 12);
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
timeValue += (hours < 12) ? " AM" : " PM";
document.jsfrm.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true
}
function startclock () {
stopclock();
showtime()
}
//-->
</script>
<BODY onLoad="startclock();">
<FORM NAME='jsfrm'>
<INPUT TYPE=text NAME='face' size=35 value=''>
</form>
[/html] |
弱弱的問一下,樓上的高手這些代碼是你自己編寫的嗎? |
金翅擘海請再幫我一下,我想只要時間2005-09-25,可自己改了總成功不了。謝謝!! |
參考
[html]<!--把以下代碼copy至你的html文件的<body>和</body>之間-->
<script>
<!-- Hide
var timerID = null
var timerRunning = false
function MakeArray(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
{
this[i] = "";
}
return this;
}
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
}
function showtime () {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var timeValue = "";
timeValue += " " + year + "-";
timeValue += ((month < 10) ? " 0" : " ") + month ;
timeValue +=" -"+date+" ";
document.jsfrm.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true
}
function startclock () {
stopclock();
showtime()
}
//-->
</script>
<BODY onLoad="startclock();">
<FORM NAME='jsfrm'>
<INPUT TYPE=text NAME='face' size=35 value=''>
</form>
[/html] |
[html]<!--把以下代碼copy至你的html文件的<body>和</body>之間-->
<script>
<!-- Hide
var timerID = null
var timerRunning = false
function MakeArray(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
{
this[i] = "";
}
return this;
}
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
}
function showtime () {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var timeValue = "";
timeValue += year + "-" + ((month < 10) ? "0" : " ") + month + "-" + date + " ";
document.jsfrm.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true
}
function startclock () {
stopclock();
showtime()
}
//-->
</script>
<BODY onLoad="startclock();">
<FORM NAME='jsfrm'>
<INPUT TYPE=text NAME='face' size=35 value=''>
</form>[/html] |
<!--把以下代碼copy至你的html文件的<body>和</body>之間-->
<script>
<!-- Hide
var timerID = null
var timerRunning = false
function MakeArray(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
{
this[i] = "";
}
return this;
}
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
}
function showtime () {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var timeValue = "";
timeValue += year + "-" + ((month < 10) ? "0" : " ") + month + "-" + ((date < 10) ? "0" : " ")+ date;
document.jsfrm.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true
}
function startclock () {
stopclock();
showtime()
}
//-->
</script>
<BODY onLoad="startclock();">
<FORM NAME='jsfrm'>
<INPUT TYPE=text NAME='face' size=35 value=''>
</form> |
[html]
<input type="text" id="time">
<script language=javascript>
var time = document.getElementById("time");
var now = new Date();
var year = now.getYear();
var month = now.getMonth()+1;
month = month <10 ?"0"+month:month;
var day = now.getDay();
day = day <10 ?"0"+day:day;
time.value = year + "-" + month + "-" + day;
</script>
[/html] |
就樓上一個自己寫的... |
你們真行!!! |
|