我在網絡編程方面很新穎。目前我嘗試使用JavaScript獲取輸入文本值,但不知道爲什麼只返回未定義的值。請幫忙。太謝謝你了~~~ 下面是我的代碼:如何使用JS獲取輸入文本值
<!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>
非常感謝,現在它的工作。 – LMayday