javascript thread: How to focus once on field A and later on field B on a jsp file?
This may not be the best solution.
You'll want to use information on your server side to conditionally
include some javascript to give the proper form element focus:
<form name=form1 method=get>
Domain: <input type=text name="DOMAIN">
<input type=submit value="Accept">
</form>
<form name=form2 method="get" action="getUser.jsp">
User: <input type=text name="USER">
<input type=submit value="Accept">
</form>
<script language="Javascript">
<% if(ServerSideJavaObject.firstTimePageWasRendered == true) { %>
document.form1.DOMAIN.focus();
<% } else if(ServerSideJavaObject.alreadyAnsweredDomain == true) { %>
document.form2.USER.focus();
<% } %>
</script>
Hope that helps (and don't forget your tabindexes!), though I'm a little
curious as to why you're having the intermediate step of submitting domain
rather than having them fill out both to begin with.
-Tim
> Hello,
> I don't know a lot about JavaScript .... that's why I have this simple
> problem!
> I have a jsp file that does as follows:
> - First the user has to fill in a text field and I want the focus on
the
> domain field.
>
> <form name=form1 method=get>
> Domain: <input type=text name="DOMAIN">
> <input type=submit value="Accept">
> </form>
>
> - When the user clicks on "Accept", the same jsp file is used and the
> user h as to enter another field value:
>
> <form name=form2 method="get" action="getUser.jsp">
> User: <input type=text name="USER">
> <input type=submit value="Accept">
> </form>
>
> I want the focus to be first on the DOMAIN field and then on the USER
fied.
> How do I do it? Please, give me an example.
>
> Thanks,
> Elisabeth
>
> Please use html