Javascript OnSubmit/JSP

L

Liquidchild

Not sure if this is the correct group, but...

I have the following jsp page, basically i want to append some text to
the username before the form is submitted, is this possible?

Thanks

S.

<HTML>
<HEAD>

<STYLE type=text/css>

A
{
FONT-SIZE: 10px;
COLOR: #000000;
FONT-STYLE: normal;
FONT-FAMILY: Arial, Helvetica, sans-serif;
TEXT-DECORATION: none
}

A:HOVER
{
color:#E600B3
}

</STYLE>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> </HEAD>

<%
String loginid = (String) session.getAttribute("loginid");
%>

<%

String errormsg = "";
int errorcode = Integer.parseInt(request.getParameter("errorcode"));

switch( errorcode )
{
case -1:
case -4:
case -5:
case -6:
case -7:
errormsg = "LDAP login failed";
break;
case -2:
errormsg = "Username not found";
break;
case -3:
errormsg = "Password Incorrect";
break;
case -8:
errormsg = "About to lock account";
break;
case -9:
errormsg = "Account locked";
break;
case -10:
errormsg = "Password Format Invalid";
break;
case -11:
errormsg = "Session expired";
break;
case -12:
errormsg = "General Error";
break;
case -13:
errormsg = "No Cookie";
break;
}
%>

<BODY bgcolor="#ffffff">
<FORM action="" method="post" name="Sales Login" target="_parent">
<%=errormsg%>
<TABLE width="100%" cellpadding="0" cellspacing="0"
class="services_bodypurp3">
<TR class="services_bodypurp3">
<TD width="30%">
<B>Username</B>
</TD>
<TD colspan="2">
<INPUT name="Username" type="text" maxlength="200" size="30">
</TD>
</TR>
<TR class="services_bodypurp3">
<TD>
<B>Password</B>
</TD>
<TD colspan="2">
<INPUT name="UserPassword" type="password" maxlength="1024"
size="20">
</TD>
</TR>
<TR class="services_bodypurp">
<TD>
&nbsp
</TD>
<TD>
<INPUT type="hidden" name="loginid" value="<%=loginid%>"/>
<INPUT name="Submit" title="Login" type="submit" value="Login">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
 
R

Richard Cornford

Liquidchild said:
Not sure if this is the correct group, but...

Is it a question about javascript?
I have the following jsp page, basically i want to append
some text to the username before the form is submitted, is
this possible?

You could use a javascript onsubmit handler to append text to the
username, inevitably needlessly introducing a dependence upon
client-side scripting. The odds are extremely good that you do not need
to do this at all, could achieve the same effect in many more reliable
ways and don't need to involve javascript here at all.
<HTML>
<HEAD>

<STYLE type=text/css>
</STYLE>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

Don't do this, you have an ability to set HTTP headers directly in JSP
so do that. HTTP-EQUIV MEAT elements are significantly less likely to
influence cashing than HTTP headers are.

Valid HTML requires the presence of a TITLE element in the HEAD of a
document.
<FORM action="" method="post" name="Sales Login" target="_parent">

Spaces in the name attributes of form elements are allowed, but I am yet
to meet anyone who thought they were a good idea. Avoid doing this,
and/or getting into this habit, as it will come back and bite you soon.

<INPUT name="UserPassword" type="password" maxlength="1024"
^^^^
That is one long password.

<INPUT type="hidden" name="loginid" value="<%=loginid%>"/>
<snip>
You pulled this - loginid - value from the session. Do you really now
need to be sending it on a round trip through the client? Won't it still
be in the session when the login request comes back?

And that slash at the end of the input tag is an error in HTML (probably
not one that will be noticed but wrong all the same). It is reminiscent
of XML/XHTML empty elements, but this document is certainly not XHTML.

Richard.
 
S

Stuart Graham

Thanks for the reply,

I have looked at doing it via the onSubmit, but i am unsure of the code
for it? Can you help?

(There are reasons for doing it at the client side rather than server
side)

Thanks

S.
 
R

Richard Cornford

Stuart said:
Thanks for the reply,

Appreciation would be better expressed in a form that followed the
well-established Usenet message construction and formatting conventions,
particularly as recognised by this group. Read:-

<URL: http://www.jibbering.com/faq/ >

- else you will shoot yourself in the foot.
I have looked at doing it via the onSubmit, but i am
unsure of the code for it? Can you help?

I could show you code that performs the action that you propose, but
that would not represent 'help' as this is not something that should
ever be done with a javascript hack (particularly as you have
server-side Java available for the task).
(There are reasons for doing it at the client side rather
than server side)

If you have reasons for wanting to do this on the client you should
state what they are. I cannot imagine any valid reason for doing so, and
so suspect that any reason you may have is based on a misconception. The
greatest help you could receive will be to have that misconception
corrected so you can do this job properly.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top