我对 Web 编程非常陌生。目前我尝试使用 JavaScript 获取输入文本值,但不知道为什么只返回未定义的值。请帮忙。非常感谢~~~下面是我的代码:
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function CurrentDate(){
var dateobj= new Date();
var date = dateobj.getDate();
var day = dateobj.getDay();
var month = dateobj.getMonth();
var year = dateobj.getFullYear();
}
function myScript(){
document.myform.date.value = CurrentDate(date);
document.myform.month.value = CurrentDate(month);
document.myform.day.value = CurrentDate(day);
document.myform.year.value = CurrentDate(year);
}
</script>
</head>
<body onload="myScript()">
<form name="myform" id="myform">
<label for ="date">date: </label>
<input id="date" type="text" name="date">
<label for ="month">month: </label>
<input id="month" type="text" name="month">
<label for ="day">day: </label>
<input id="day" type="text" name="day">
<label for ="year">year: </label>
<input id="year" type="text" name="year">
</form>
</body>
</html>