【请教高手错误提示:“为空或不是对象”!解决立即给分】

tacit 2004-07-08 05:18:38
运行前请勾选ie属性----》高级---》显示错误脚本通知,显示友好的HTTP错误信息,显示友好的URL信息三项!!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<style>
.a3{width:25;border:0;text-align:center}
</style>
<script>
function mask(obj){
obj.value=obj.value.replace(/[^\d]/g,'')
key1=event.keyCode
if (key1==37 || key1==39)
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
if(obj.value.length>=3)
if(parseInt(obj.value)>=256 || parseInt(obj.value)<=0)
{
alert(parseInt(obj.value)+"IP地址错误!")
obj.value=""
obj.focus()
return false;
}
else
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
}
function mask_c(obj)
{
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))
}

</script>
<title>IP地址输入</title>

</head>
<body>IP地址输入
<div style="border-width:1;border-color:balck;border-style:solid;width:120;font-size:8pt">
<input type=text name="ip1" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip2" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip3" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip4" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">
</div>
</body>
</html>
保存为ip.asp服务器上运行!!
开始提示我对象没有定义,当我把ip1,ip2,ip3,ip4都定义后,仍然提示我“对象为空或不是对象?”为何????????????
...全文
498 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
tacit 2004-07-09
  • 打赏
  • 举报
回复
昨天的问题,再请教一下:
IP输入两位时按向左键和向右键(“->”和“〈-”)时同样会出错,能不能这样:
按向左键跳到上一个输入框,按向右键跳到下一个输入框?

拜托了,谢谢
tacit 2004-07-08
  • 打赏
  • 举报
回复
好了,谢谢!~
wanghr100 2004-07-08
  • 打赏
  • 举报
回复
eval("ip"+nextip+".focus()")

你的代码还是没有改啊 :(

//原来是:eval("ip"+nextip+".focus()")改了一下,行了.
eval("document.login.ip"+nextip+".focus()")
tacit 2004-07-08
  • 打赏
  • 举报
回复
<HTML>
<HEAD>
<TITLE>aaaa</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<link href="../inc/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function mask(obj)
{
obj.value=obj.value.replace(/[^\d]/g,'')
key1=event.keyCode
if (key1==37 || key1==39)
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
if(obj.value.length>=3)
if(parseInt(obj.value)>=256 || parseInt(obj.value)<=0)
{
alert(parseInt(obj.value)+"IP地址错误!")
obj.value=""
obj.focus()
return false;
}
else
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
}
function mask_c(obj)
{
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))
}
--->
</script>
</HEAD>
<BODY BGCOLOR=#E7E7E7 LEFTMARGIN=7 TOPMARGIN=7 RIGHTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<table width="100%" border="1" cellpadding="3" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<form name="login" method="post" action="act_config.asp?action=add_seat">
<tr bgcolor="#D1D1D1">
<td height="24" colspan="2" align="center">添加座席</td>
</tr>
<tr>
<td width="13%" align="center">IP设置</td>
<td width="87%">
<div style="border-width:1;BACKGROUND-COLOR:white;border-style:solid;width:140;height:20;">
<input type="text" name="ip1" maxlength=3 class="a3" onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type="text" name="ip2" maxlength=3 class="a3" onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type="text" name="ip3" maxlength=3 class="a3" onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type="text" name="ip4" maxlength=3 class="a3" onkeyup="mask(this)" onbeforepaste="mask_c()">
</div>
</td>
</tr>
<tr>
<td align="center">座席号</td>
<td><input name="SEATNUM" type="text" id="SEATNUM" onkeyup="device_id(this)" size="2">
【只能输入1-10】</td>
</tr>
<tr>
<td align="center">备注信息</td>
<td><textarea name="NOTES" cols="80" rows="6" id="NOTES"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"> <input type="submit" name="Submit" value="提交" class="unite">
   <input type="reset" name="reset" value="重置" class="unite"></td>
</tr>
</form>
</table>
</BODY>
</HTML>
保存为ip.asp调试吧!谢谢
tacit 2004-07-08
  • 打赏
  • 举报
回复
我放在asp的页面中仍然出现:
"ip2没有定义“

”ip3没有定义“

”ip4没有定义“
gjd111686 2004-07-08
  • 打赏
  • 举报
回复
1.将你的ip1等定义为id试
2.eval("document.all.ip"+nextip+".focus()")
wanghr100 2004-07-08
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<style>
.a3{width:25;border:0;text-align:center}
</style>
<script>
function mask(obj){
obj.value=obj.value.replace(/[^\d]/g,'')
key1=event.keyCode
if (key1==37 || key1==39)
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
if(obj.value.length>=3)
if(parseInt(obj.value)>=256 || parseInt(obj.value)<=0)
{
alert(parseInt(obj.value)+"IP地址错误!")
obj.value=""
obj.focus()
return false;
}
else
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
//原来是:eval("ip"+nextip+".focus()")改了一下,行了.
eval("document.login.ip"+nextip+".focus()")
}
}
function mask_c(obj)
{
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))
}

</script>
<title>IP地址输入</title>

</head>
<body>
<form name="login" action="111.asp">
IP地址输入
<div style="border-width:1;border-color:balck;border-style:solid;width:150;font-size:8pt">
<input type=text name="ip1" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip2" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip3" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip4" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">
</div>
</form>
</body>
</html>
tacit 2004-07-08
  • 打赏
  • 举报
回复
但是这样怎么会处错呀???
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<style>
.a3{width:25;border:0;text-align:center}
</style>
<script>
function mask(obj){
obj.value=obj.value.replace(/[^\d]/g,'')
key1=event.keyCode
if (key1==37 || key1==39)
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
if(obj.value.length>=3)
if(parseInt(obj.value)>=256 || parseInt(obj.value)<=0)
{
alert(parseInt(obj.value)+"IP地址错误!")
obj.value=""
obj.focus()
return false;
}
else
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
}
function mask_c(obj)
{
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))
}

</script>
<title>IP地址输入</title>

</head>
<body>
<form name="login" action="111.asp">
IP地址输入
<div style="border-width:1;border-color:balck;border-style:solid;width:150;font-size:8pt">
<input type=text name="ip1" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip2" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip3" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">.
<input type=text name="ip4" maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste="mask_c()">
</div>
</form>
</body>
</html>
kingdomzhf 2004-07-08
  • 打赏
  • 举报
回复
在ie6.0.2600.00000中没问题啊
wanghr100 2004-07-08
  • 打赏
  • 举报
回复
你的代码没问题 :)
windows2000Ser+IE6.0SP1

可能不在这代码里面.
tacit 2004-07-08
  • 打赏
  • 举报
回复
请分析一下下面的原因:
开始提示我对象没有定义,当我把ip1,ip2,ip3,ip4都定义后,仍然提示我“对象为空或不是对象?”为何????????????
chenxiaohan 2004-07-08
  • 打赏
  • 举报
回复
没有问题啊。
tacit 2004-07-08
  • 打赏
  • 举报
回复
自己顶一下!!

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧