在html中访问控件为什么老是说为空或不存在?
<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 老是说对象为空或不存在?
------解决方案--------------------document对象使用的不对,找不到对象啊
------解决方案--------------------var txtObj = document.getElementById( "ServiceNameText1 ");
txtObj就是你的text框,你可以根据属性做你想做的
这个函数的大小写可能不对,你自己查一下吧