我想用JavaScript来启动一个选框,当用户把他们的名字放入一个文本框然后点击一个按钮。我已经知道如何去做,但我的脚本从未完全正常工作。任何帮助表示赞赏!如何根据用户输入使用JavaScript启动选取框?
这是我到目前为止有:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function StartMarquee() {
var text = document.getElementById(namebox);
if (text != null) {
document.write("<marquee behavior='scroll' direction='right'>Hello " + text + "!</marquee>");
}
else {
alert("Enter your name first!!!");
}
}
</script>
</head>
<body>
<table style="margin:0px auto 0px auto;">
<tr><td>Enter your name!</td>
<td><input type="text" id="namebox"/></td>
<td><input type="button" value="Enter" onclick="StartMarquee()"/></td></tr>
</table>
</body>
</html>
“永不完全有效”是什么意思? – 2010-03-18 01:25:44
永不完全的作品意味着它会吐出一条提示消息,提示“先输入用户名!”或者它会播放一个说“Hello null!”的选取框。 – 2010-03-18 01:31:54