you can do it like this

<script language="javascript">
function focusFirst(){
        document.frmEmployee.txtName.focus();
}
</script>
<body onLoad="focusFirst()">
<form action="#" name="frmEmployee">
<input type="text" name="txtName" value="tata">
</form>

-----Original Message-----
From: Henry S. Hayden [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 28, 2002 3:16 PM
To: [EMAIL PROTECTED]
Subject: Re: Setting focus in JSP


Here is a little more background, which I probably should have included:
The firstfocus() function is called from the JSP's BODY ONLOAD event.  I'm
using Communicator 4.77 and IE 5.  It does not work with either one.  There
is no error message, either.  The form appears properly, except that focus
is not set as I would like.

Thanks!

Henry


-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of dave
Sent: Thursday, February 28, 2002 4:09 PM
To: [EMAIL PROTECTED]
Subject: Re: Setting focus in JSP

Henry,

      I don't know why this code didn't worked. I tryed it in
      differents way, and they all worked in IE 6 and mozilla 0.9.8
      Not in Netscape 4.78 anyway, without any error.

Watch my code :

<form action="#" name="frmEmployee">
<input type="text" name="txtName" value="tata">
<a href="#" onMouseOver="FirstFocus()">focus</a> <!-- work -->
</form>
<Script LANGUAGE="JavaScript" TYPE="text/javascript">
setTimeout("document.frmEmployee.txtName.select()",200)  //work
document.frmEmployee.txtName.select();                   //work

function FirstFocus() {
        document.frmEmployee.txtName.select();
}
document.onLoad=FirstFocus()                               //work
</script>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to