Hi!
This task is cerainly feasible, though not advisable to do so.
Performing these kind of checks on client-side means that you need to hold
some data
in your page in form of some variables ( as part of <form> tag).
So you can first query for all the employee-ids in your jsp page and store
those
employee-ids in an array of hidden variables.
Then you can modify your code as follows:
<script>
function change(){
var value1;
var loopCounter;
// This line will automatically pick up the run-time value
from your text-box
value1=documet.formname.emp_no.value;
for(loopCounter=0; loopCounter<
document.formname.hiddenArrayName.length; loopCounter++)
{
if
(document.formname.hiddenArrayName[loopCounter].value=value1)
{
alert("Employee allready exists");
//write some logic to handle this situation
and exit out of loop from here
}
}
}
</script>
This method is advisable only when data is quite less.
But Bhushan is right in saying that it is mostly advisable to go to server
because that strategy is
more efficient.
Hopefully that clears your doubt.
Rg,
Sandeep
Disclaimer:
This document is intended for transmission to the named recipient only. If
you are not that person, you should note that legal rights reside in this
document and you are not authorized to access, read, disclose, copy, use or
otherwise deal with it and any such actions are prohibited and may be
unlawful. The views expressed in this document are not necessarily those of
HCL Technologies Ltd. Notice is hereby given that no representation,
contract or other binding obligation shall be created by this e-mail, which
must be interpreted accordingly. Any representations, contractual rights or
obligations shall be separately communicated in writing and signed in the
original by a duly authorized officer of the relevant company.
-----Original Message-----
From: Bhushan_Bhangale [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 02, 2002 2:01 PM
Subject: Re: how to pass current value in function of jsp?
No shortcut you have to go serverside to check whether that employee already
exists or not.
-----Original Message-----
From: Vaishali S. Pandya [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 02, 2002 10:27 AM
To: [EMAIL PROTECTED]
Subject: Re: how to pass current value in function of jsp?
Yes bhushan u r right
i did check this today only and got the point
actually i wanted to do something like shortcut so i do not have to submit
my page
but no alternate is there i suppose and i have to go for it.
right?
Thanks
Vaishali
Reliance Ind Ltd
A'bad
Bhushan_Bhangale
<Bhushan_Bhangale@I To:
[EMAIL PROTECTED]
NFOSYS.COM> cc:
Sent by: A mailing Subject: Re: how to pass
current value in function of jsp?
list about Java
Server Pages
specification and
reference
<JSP-INTEREST@JAVA.
SUN.COM>
07/02/02 10:34 AM
Please respond to A
mailing list about
Java Server Pages
specification and
reference
Hello Vaishali,
I guess you are doing something wrong here. Tell me are you thinking that
when the onBlur event will occur your code will execute the
checkemp(String) method? If yes then you are wrong as the checkemp method
will execute when the JSP will get served. So in the source of generated
html you will see onBlur="change(true/false)" already written there. This
way you can't pass the emp_no value tho that method. To do so you need to
submit the form to serverside.
-----Original Message-----
From: Vaishali S. Pandya [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 5:01 PM
To: [EMAIL PROTECTED]
Subject: how to pass current value in function of jsp?
<%!
public static boolean checkemp(String emp){
MyConnection con=new MyConnection();
Statement stmt = null;
ResultSet rs = null;
try{
stmt = con.getCon(1);
rs = stmt.executeQuery("select * from hrm_employee_mas
where emp_employee_no = " + emp);
if (rs.next()){
return (true);
}
else{
return (false);
}
}
catch(Exception e){
System.out.println(e);
}
return (true);
}
%>
<script>
function change(res){
if (res==true){
alert("Employee allready exists");
document.femp.emp_no.focus();
}
</script>
<INPUT type=text name=emp_no value="<%=emp%>" onblur="change(<%=checkemp
(?)%>)">
what should i write here ?
i want to pass current value of emp_no
in javascript i can write this.value
what about jsp?
any idea?
Thanks in advace
Regards
Vaishali
Reliance Ind Ltd
A'bad
===========================================================================
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
===========================================================================
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