javascript能否直接获得html表单数据
<body>
<form action="index.html" method="post">请输入您的姓名
<input type="text" name="age" id="age">
<input type="submit" value="提交">
</form>
<script type="text/JavaScript">
var myage=document.getElementById("age").value;
if(myage<=44)
{document.write("青年");}
else if(myage<=59)
{document.write("中年人");}
else if(myage<=89)
{document.write("老年人");}
else
{document.write("长寿老年人");}
</script>
</body>
没成功(╯‵□′)╯︵┻━┻是哪错了还是根本就不行