onBlur 函数未执行
我几个小时以来一直在寻找为什么这不起作用的答案,但我很困惑。
这是包含 javascript 和所涉及表单的脚本。
<script language="Javascript" type="text/javascript">
function complete(init){
alert ("in function with " + init);
var aList = new Array(<?php echo $aList; ?>);
var iList = new Array(<?php echo $iList; ?>);
for (var i = 0; i < iList.length; i++){
if (init == iList[i]){
alert ("replacing " + init + " with " + aList[i]);
this.frmMain.txtAtty.value = aList[i];
}
}
}
</script>
<FORM METHOD="POST" NAME="frmMain" ACTION=<?php echo $_SERVER["PHP_SELF"]; ?>>
<table width="75%" align="center">
<tr>
<td width="25%" align="right">Name:</td>
<td>
<input type="text" name="txtSender" size="30" value=""/><span class="noteText"> Your Name</span>
</td>
</tr>
<tr>
<td width="25%" align="right">Attorney:</td>
<td>
<input type="text" name="txtAtty" size="30" value="" onblur = "complete(this.value)">
</td>
</tr>
两个 PHP echo 语句是数组的参数。 Complete(this.value) 函数应该采用 3 个字母的代码(在 iList 数组中)并用名称替换它。警报在那里用于调试目的,但当我运行该页面时,我没有收到任何警报。有什么想法吗?
I've been searching for an answer for why this isn't working for several hours, and I'm stumped.
Here's the script including the javascript and form involved.
<script language="Javascript" type="text/javascript">
function complete(init){
alert ("in function with " + init);
var aList = new Array(<?php echo $aList; ?>);
var iList = new Array(<?php echo $iList; ?>);
for (var i = 0; i < iList.length; i++){
if (init == iList[i]){
alert ("replacing " + init + " with " + aList[i]);
this.frmMain.txtAtty.value = aList[i];
}
}
}
</script>
<FORM METHOD="POST" NAME="frmMain" ACTION=<?php echo $_SERVER["PHP_SELF"]; ?>>
<table width="75%" align="center">
<tr>
<td width="25%" align="right">Name:</td>
<td>
<input type="text" name="txtSender" size="30" value=""/><span class="noteText"> Your Name</span>
</td>
</tr>
<tr>
<td width="25%" align="right">Attorney:</td>
<td>
<input type="text" name="txtAtty" size="30" value="" onblur = "complete(this.value)">
</td>
</tr>
The two PHP echo statements are the parameters for the Arrays. The complete(this.value) function is supposed to take a 3 letter code (in the iList array) and substitute it with a name. The alerts are in there for debugging purposes, but i don't get either alert when i run the page. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
this.frmMain
没有在任何地方定义
更改
使用
和
this.frmMain
is not defined anywhere
change
to
and use