473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Javascript OnSubmit/JSP

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>

Nov 2 '05 #1
3 5223
Liquidchild wrote:
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> <snip> </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.
</HEAD>
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.

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

<snip> <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.
Nov 2 '05 #2


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.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 3 '05 #3
Stuart Graham wrote:
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.

Nov 4 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
7
by: Michel | last post by:
Hi all, Is there some intelligent way to trigger a clientside JavaScript function before a postback is triggerd by any of the controls on a page? Thanks in advance, Michel Mathijssen
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
4
by: houstoncity2004 | last post by:
Hi, I need help to JavaScript. I am new to this, and am trying to the page online ASAP. I have two submit buttons on one form, and each button will have to do different things. I named both...
2
by: horos | last post by:
just another thing.. for people who are trying to replace a url outside of a form and who are searching for an answer - when you are trying to use the document.location.replace("") method for going...
2
by: Sean Dockery | last post by:
Which is the following is correct? a) <form ... onSubmit="return checkData()"> b) <form ... onSubmit="return checkData();"> c) <form ... onSubmit="checkData()"> d) <form ......
10
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
3
by: jason | last post by:
I have a very simple asp.net 2.0 page with one textbox that onkeyPress is suppose to do some check of what was typed. Below is the source showing the javascript function is available. The minute I...
1
by: tgorton | last post by:
I am having a problem running a javascript function as part of an html-el:form onsubmit. The problem seems to exists in IE6 but not in Firefox. html: <html-el:form action="${target}"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.