我的函数没有执行onClick,并警告输入值

时间:2012-12-05 20:00:42

标签: javascript html

<HTML>
<HEAD>
<TITLE>Test Input</TITLE>
<script type="text/javascript">
function go (form) {
  var Tid = document.upperform.inputbox.value;
  alert ("You typed: " + Tid);
    //window.location.href = 'http://serverpage=' + Tid + '&tab=0';
</script>

</HEAD>
<BODY>
<FORM NAME="upperform" ACTION="" METHOD="GET">Go to this Task ID:
    <INPUT TYPE="text" NAME="inputbox" VALUE="" OnBlur="validate(this.form)">
    <INPUT TYPE="button" NAME="button" Value=" Go " onClick="go(this.form)">
</FORM>
</BODY>
</HTML>

我无法让这个工作。它看起来应该有效,但我一定错过了什么。有什么建议吗?

2 个答案:

答案 0 :(得分:0)

你错过了函数的结尾括号。除此之外,代码有效:http://jsfiddle.net/45paz/

function go (form) {
  var Tid = document.upperform.inputbox.value;
  alert ("You typed: " + Tid);
}

答案 1 :(得分:0)

缺少结束括号

<script type="text/javascript">
function go (form) {
  var Tid = document.upperform.inputbox.value;
  alert ("You typed: " + Tid);
    //window.location.href = 'http://serverpage=' + Tid + '&tab=0';
}// <- missing bracket
</script>