javascript显示错误 对象不支持此属性或方法
<HTML><HEAD><TITLE>Untitled</TITLE></HEAD><SCRIPTtype=""language="javascript">functio...
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<SCRIPT type="" language="javascript">
function checkSFZ()
{
var objspanSFZ=document.getELementById("spanSFZ");
var strSFZ=document.txtSFZ.value;
var objspanSFZ=document.txtSFZ;
if(strSFZ==0)
{
objspanSFZ.innerHTML="<FONT color='red'>1233</FONT>";
return;
}
objspanSFZ.innerHTML="<FONT color='blue'>3214</FONT>";
}
</SCRIPT>
<BODY>
<TABLE border="1" width="400px" align="center">
<TR>
<TD>身份证</TD>
<TD><INPUT TYPE="text" name="txtSFZ"></INPUT></TD>
<TD><SPAN Id="spanSFZ"></SPAN></TD>
</TR>
</TR>
<TR>
<TD><INPUT TYPE="button" value="输入" onclick="checkSFZ();"></INPUT></TD>
</TR>
</TABLE>
</BODY>
</HTML>
这个的问题是:对象不支持此属性或方法
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<SCRIPT type="" language="javascript">
function checkSalary()
{
var objspanSalary=document.getElementById("spanSalary");
var strSalary=document.form1.txtSalary.value;
var objspanSalary=document.form1.txtSalary;
if(strSalary==0)
{
objspanSalary.innerHTML="<FONT color='red'>输入没有效!</FONT>";
return;
}
objspanSalary.innerHTML="<FONT color='blue'>输入有效!</FONT>";
}
</SCRIPT>
<BODY><TABLE action="" name="form1"></TABLE>
<TABLE border="1" width="400px" align="center">
<CAPTION>信息管理</CAPTION>
<TR>
<TD>工资</TD>
<TD><INPUT TYPE="text" name="txtSalary" value=""></INPUT></TD>
<TD><SPAN Id="spanSalary">请输入数字</SPAN></TD>
</TR>
<TR>
<TD><INPUT TYPE="button" value="输入" onclick="checkSalary();"></INPUT></TD>
</TR>
</TABLE>
</BODY>
</HTML>
这个的问题是:document.form1.txtSalary;为空或不是对象.
急!! 展开
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<SCRIPT type="" language="javascript">
function checkSFZ()
{
var objspanSFZ=document.getELementById("spanSFZ");
var strSFZ=document.txtSFZ.value;
var objspanSFZ=document.txtSFZ;
if(strSFZ==0)
{
objspanSFZ.innerHTML="<FONT color='red'>1233</FONT>";
return;
}
objspanSFZ.innerHTML="<FONT color='blue'>3214</FONT>";
}
</SCRIPT>
<BODY>
<TABLE border="1" width="400px" align="center">
<TR>
<TD>身份证</TD>
<TD><INPUT TYPE="text" name="txtSFZ"></INPUT></TD>
<TD><SPAN Id="spanSFZ"></SPAN></TD>
</TR>
</TR>
<TR>
<TD><INPUT TYPE="button" value="输入" onclick="checkSFZ();"></INPUT></TD>
</TR>
</TABLE>
</BODY>
</HTML>
这个的问题是:对象不支持此属性或方法
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<SCRIPT type="" language="javascript">
function checkSalary()
{
var objspanSalary=document.getElementById("spanSalary");
var strSalary=document.form1.txtSalary.value;
var objspanSalary=document.form1.txtSalary;
if(strSalary==0)
{
objspanSalary.innerHTML="<FONT color='red'>输入没有效!</FONT>";
return;
}
objspanSalary.innerHTML="<FONT color='blue'>输入有效!</FONT>";
}
</SCRIPT>
<BODY><TABLE action="" name="form1"></TABLE>
<TABLE border="1" width="400px" align="center">
<CAPTION>信息管理</CAPTION>
<TR>
<TD>工资</TD>
<TD><INPUT TYPE="text" name="txtSalary" value=""></INPUT></TD>
<TD><SPAN Id="spanSalary">请输入数字</SPAN></TD>
</TR>
<TR>
<TD><INPUT TYPE="button" value="输入" onclick="checkSalary();"></INPUT></TD>
</TR>
</TABLE>
</BODY>
</HTML>
这个的问题是:document.form1.txtSalary;为空或不是对象.
急!! 展开
5个回答
展开全部
给你个简单的Javascript例子。仔细看看啊!
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null,rs1=null,rs2=null;
String sql;
int count;
int count2;
String drivername="com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost/selectbiao";
try{
Class.forName(drivername);
conn=DriverManager.getConnection(url,"root","root");
stmt=conn.createStatement();
sql="中仔乱select * from city order by locationid asc";
rs=stmt.executeQuery(sql);
}catch(SQLException e){
System.out.println(e.getMessage());
}
%>
<script language="javascript">
var onecount;
onecount=0;
subcat=new Array();
<%
count=0;
while(rs.next()){
%>
subcat[<%=count%>]=new Array("<%=rs.getString("districtname")%>","<%=rs.getInt("locationid")%>","<%=rs.getInt("districtid")%>");
<%
count = count + 1 ;
}
rs.close();
rs=null;
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.smalllocation.length=0;
document.myform.village.length = 0;
document.myform.village.options[0] = new Option('戚罩==所选地区的县区==','');
document.myform.smalllocation.options[0]=new Option('==所选城市的地区==','');
for(i=0;i<onecount;i++)
{
if (subcat[i][1] == locationid)
{
document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>卖档
<%
sql="select * from village order by districtid asc";
rs2=stmt.executeQuery(sql);
%>
<script language="javascript">
var onecount2;
onecount2=0;
subcat2=new Array();
<%
count2=0;
while(rs2.next()){
%>
subcat2[<%=count2%>]=new Array("<%=rs2.getString("villagename")%>","<%=rs2.getInt("districtid")%>","<%=rs2.getInt("villageid")%>");
<%
count2 = count2 + 1 ;
}
rs2.close();
rs2=null;
%>
onecount2=<%=count2%>;
function changelocation2(districtid)
{
document.myform.village.length = 0;
document.myform.village.options[0] = new Option('==所选地区的县区==','');
for (j=0;j < onecount2; j++)
{
if (subcat2[j][1] == districtid)
{
document.myform.village.options[document.myform.village.length] = new Option(subcat2[j][0], subcat2[j][2]);
}
}
}
</script>
</head>
<body>
<form name="myform" method="post">
分类:<select name="biglocation" onChange="changelocation(this.value)" size="1">
<option selected>请选择你所在的省市</option>
<%
sql ="select * from province order by locationname asc";
rs1 = stmt.executeQuery(sql);
while(rs1.next()){
%>
<option value="<%=rs1.getInt("locationid")%>"><%=rs1.getString("locationname")%></option>
<%
}
rs1.close();
rs1 = null;
conn.close();
conn =null;
%>
</select>
<select name="smalllocation" onChange="changelocation2(document.myform.smalllocation.options[document.myform.smalllocation.selectedIndex].value)">
<option selected value="">==所有地区==</option>
</select>
<select name="village" size="1">
<option selected>==所有县区==</option>
</select>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null,rs1=null,rs2=null;
String sql;
int count;
int count2;
String drivername="com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost/selectbiao";
try{
Class.forName(drivername);
conn=DriverManager.getConnection(url,"root","root");
stmt=conn.createStatement();
sql="中仔乱select * from city order by locationid asc";
rs=stmt.executeQuery(sql);
}catch(SQLException e){
System.out.println(e.getMessage());
}
%>
<script language="javascript">
var onecount;
onecount=0;
subcat=new Array();
<%
count=0;
while(rs.next()){
%>
subcat[<%=count%>]=new Array("<%=rs.getString("districtname")%>","<%=rs.getInt("locationid")%>","<%=rs.getInt("districtid")%>");
<%
count = count + 1 ;
}
rs.close();
rs=null;
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.smalllocation.length=0;
document.myform.village.length = 0;
document.myform.village.options[0] = new Option('戚罩==所选地区的县区==','');
document.myform.smalllocation.options[0]=new Option('==所选城市的地区==','');
for(i=0;i<onecount;i++)
{
if (subcat[i][1] == locationid)
{
document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>卖档
<%
sql="select * from village order by districtid asc";
rs2=stmt.executeQuery(sql);
%>
<script language="javascript">
var onecount2;
onecount2=0;
subcat2=new Array();
<%
count2=0;
while(rs2.next()){
%>
subcat2[<%=count2%>]=new Array("<%=rs2.getString("villagename")%>","<%=rs2.getInt("districtid")%>","<%=rs2.getInt("villageid")%>");
<%
count2 = count2 + 1 ;
}
rs2.close();
rs2=null;
%>
onecount2=<%=count2%>;
function changelocation2(districtid)
{
document.myform.village.length = 0;
document.myform.village.options[0] = new Option('==所选地区的县区==','');
for (j=0;j < onecount2; j++)
{
if (subcat2[j][1] == districtid)
{
document.myform.village.options[document.myform.village.length] = new Option(subcat2[j][0], subcat2[j][2]);
}
}
}
</script>
</head>
<body>
<form name="myform" method="post">
分类:<select name="biglocation" onChange="changelocation(this.value)" size="1">
<option selected>请选择你所在的省市</option>
<%
sql ="select * from province order by locationname asc";
rs1 = stmt.executeQuery(sql);
while(rs1.next()){
%>
<option value="<%=rs1.getInt("locationid")%>"><%=rs1.getString("locationname")%></option>
<%
}
rs1.close();
rs1 = null;
conn.close();
conn =null;
%>
</select>
<select name="smalllocation" onChange="changelocation2(document.myform.smalllocation.options[document.myform.smalllocation.selectedIndex].value)">
<option selected value="">==所有地区==</option>
</select>
<select name="village" size="1">
<option selected>==所有县区==</option>
</select>
</form>
</body>
</html>
展开全部
<TABLE action="" name="form1"></TABLE> 粗段世物心了吧?table标签怎么会有action属性呢?
另外还要把表单返枣控件包在form里才对握液
另外还要把表单返枣控件包在form里才对握液
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这人真是基础都没有,乱七八糟
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
怎么说呢,你看一下这个getELementById。应该是getElementById
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是哦,你这都没有<form></form>标签,怎么会有form1呢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询