eric liu wrote:
> Hello there: I am trying to program a servlet which interact with client
> through a set of navigation buttons (using form). I put the javascript in
> a separate file, the script like this:
> function showDetails(butt){
> if(butt=="next"){do something}
> if(butt=="previous"){do something}
> etc.
> }
> and in the servlet, I defined a form name "memberlookup" which includes
> these hidden values:
> <input type="hidden" name="rowid1" value="start">
> <input type="hidden" name="rowid2" value="end">
> <input type="hidden" name="totalrecords" value=totalrecords>
> and button types as:
> <input type=button name="nxet" value=" > " onClick="showDetail('next')">
> etc.
>
> When I test the button, the browser give me error:
> 'document.memberlookup.rowid2' is not an object.
>
> But when I put the javascript in the servlet, it works. I am wondering
> if there is any difference between coding it in the servlet and puting
> it in a file. Any help is appreciated. Eric Liu
>
There is a difference. The JavaScript "document" object refers to the
document that this script is in. When you put the function in the same page
as the form, it's the same "document" object so it works. (Servlet generated
or static HTML does not matter, by the way). When you put the script in a
different file, it's "document" object is different, so the form object is not
available.
There are a variety of ways in JavaScript for scripts in one page to refer to
objects in another -- I suggest you check out a JavaScript guide, or ask
questions on a JavaScript related list.
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html