Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: document is not object error


Message #1 by Edward King <zhangsc@n...> on Wed, 19 Feb 2003 11:29:47 +0800
	If you've got problem with client-side JavaScript, don't reason in
terms of JSP.  Do the reasoning by inspecting the resultant HTML file.  
Have
you taken a look at the "source page" ?  Maybe you could see what's 
wrong.

	Nevertheless, I've seen a little syntax problem.  There's an extra
<body> tag in your body.jsp file.  Maybe that's the cause.

	OTOH, why is there this
<%@ page contentType=3D"text/html" %>
in body.jsp?  Is this necessary?  If yes, why isn't it put rather in
total.jsp?  I would expect it to be put either in total.jsp or in all 
three
*.jsp included files.

	Lastly, if none can solve the problem, try
document.forms["newUserForm"].submit();

> -----Message d'origine-----
> De : Edward King [mailto:zhangsc@n...]
> Envoy=C3=A9 : mercredi 19 f=C3=A9vrier 2003 04:30
> =C3=80 : javascript
> Objet : [javascript] document is not object error
>
>
> I have a question about Javascript,this question puzzled me
> for a long time. I put Javascript in my JSP file.But
> Javascript raise errors.My structure is a bit complicated. I
> have a jsp file named total.jsp,it includes three JSP file.
> one JSP file "body.jsp" contains JavaScript.My purpose is to
> run total.jsp first,and from total.jsp,I run body.jsp,so I
> can run JavaScript in it.But when I run it,it raise errors:
>  line:10
>  error:document.newUserForm is not object
>
> Why raise this error? Please help me.My files are follows:
>
>
> total.jsp
>  -----------
> | title.jsp |
> | body.jsp  |
> | foot.jsp  |
>  -----------
>
> /*total.jsp*/
> <html>
> <head>
>   <title>total</title>
> </head> 
> <body>
>   <%@ include file=3D"title.jsp" %>
>   <%@ include file=3D"body.jsp" %>
>   <%@ include file=3D"foot.jsp" %>
> </body> 
> </html>
>
> /*title.jsp*/
> <p>This is title jsp</p>
>
> /*foot.jsp*/
> <p>This is foot jsp</p>
>
> /*foot.jsp*/
> <%@ page contentType=3D"text/html" %>
> <script language=3D"JavaScript">
> function trans()
> {
>   document.newUserForm.submit();
> }
> </script>
> <body>
> <form method=3D"post" action=3D"addUser.jsp" name=3D"newUserForm">
>  <p>
>    <input type=3D"button" name=3D"Submit" onclick=3D"trans()">
> </form> 
>
> Thanks in advance
>

  Return to Index