自动日期代码不起作用 [英] Auto date code wont work
本文介绍了自动日期代码不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮我吗?我有一个问题,让它在输入框中显示日期。 (这不是我的代码)。
< < span class =code-leadattribute>!DOCTYPE HTML PUBLIC - / / W3C // DTD HTML 4.01 // EN http:// www.w3.org/TR/html4/strict.dtd\">
< html >
< ; head >
< 跨度> < span class =code-leadattribute> meta http-equiv = Content-Type 内容 = text / html; charset = iso-8859-1 / >
< title > Untitled Document < / title >
< script 类型 = text / javascript >
var d = new Date ();
var monthname = new 数组( 1月, 2月,< span class =code-string> March, April, May, June, 七月, 八月, 九月, 十月 , 11月, 12月);
// 确保语言正确。英语是2004年1月1日
var TODAY = monthname [d.getMonth()] + + d.getDate()+ , + d.getFullYear();
function today(){
document .getElementById( txtBox)。value = TODAY;
}
< / 脚本 >
< / head >
< body >
< 表格 >
< input type = text 名称 = txtBox >
< 输入 类型 = 按钮 value = 今天 onclick = today() >
< / form >
< / body >
< / html >
谢谢!
Joel。
解决方案
请尝试以下代码
< html < span class =code-keyword>>
< head >
< meta http-equiv = 内容类型 内容 = text / html; charset = iso-8859-1 / >
< title > Untitled Document < / title >
< script 类型 = text / javascript >
var d = new Date();
var monthname = new Array(January,February ,March,April,May,June,July,August,September,October,November,December);
//确保正确的语言。英语是2004年1月1日
var TODAY = monthname [d.getMonth()] ++ d.getDate()+,+ d.getFullYear();
函数today()
{
document.getElementById('txtBox')。value = TODAY.toString();
返回false;
}
< / script >
< / head >
< body >
< 表格 >
< 输入 类型 = text name = txtBox id = txtBox >
< 输入 类型 = 按钮 value = 今天 onclick = 今天返回() >
< / form >
< / body >
< / html > 跨度>
Can anyone help me with this? I have a problem getting it to show the date in the input box. (this isn't my code).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
function today(){
document.getElementById("txtBox").value = TODAY;
}
</script>
</head>
<body>
<form>
<input type="text" name="txtBox">
<input type="button" value="Today" onclick="today()">
</form>
</body>
</html>
Thanks!
Joel.
解决方案
Please try following code
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript"> var d = new Date(); var monthname = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); //Ensure correct for language. English is "January 1, 2004" var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear(); function today() { document.getElementById('txtBox').value = TODAY.toString(); return false; } </script> </head> <body> <form> <input type="text" name="txtBox" id="txtBox"> <input type="button" value="Today" onclick="return today()"> </form> </body> </html>
这篇关于自动日期代码不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文