<html>
<head>
</head>
<body>
<form name="form1" id="form1" method="post" action="MyShowInvoke.jsp">
<Table id="Table1" width="100%" BORDER="1">
<tr width="100%">
<td width="50%" align="center" >
<input type="text" name="ServiceNameText1" id="ServiceNameText1"
value="j" size="50">
</td>
<td width="20%" align="center" >
<input type="button" name="doService" value="执行服务!" onClick="checkNull();">
</td>
</tr>
</Table>
<script language="javascript">
function checkNull(){
if (document.form1.Table1.tdtext1.ServiceNameText1.value="")
{alert("请选择一个服务!");}
}
</script>
</form>
</body>
<html>为什么:document.form1.Table1.tdtext1.ServiceNameText1.value 老是说对象为空或不存在?
<head>
</head>
<body>
<form name="form1" id="form1" method="post" action="MyShowInvoke.jsp">
<Table id="Table1" width="100%" BORDER="1">
<tr width="100%">
<td width="50%" align="center" >
<input type="text" name="ServiceNameText1" id="ServiceNameText1"
value="j" size="50">
</td>
<td width="20%" align="center" >
<input type="button" name="doService" value="执行服务!" onClick="checkNull();">
</td>
</tr>
</Table>
<script language="javascript">
function checkNull(){
if (document.form1.Table1.tdtext1.ServiceNameText1.value="")
{alert("请选择一个服务!");}
}
</script>
</form>
</body>
<html>为什么:document.form1.Table1.tdtext1.ServiceNameText1.value 老是说对象为空或不存在?
txtObj就是你的text框,你可以根据属性做你想做的
这个函数的大小写可能不对,你自己查一下吧
两种写法都正确