aspose file tools*
The moose likes JSP and the fly likes Form in Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Form in Jsp" Watch "Form in Jsp" New topic
Author

Form in Jsp

rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
I have a form in jsp consisting of emp no and emp name.
Now what i want is when i enter emp no than emp name of that employee should automatically be displayed fetching from database.
Please help
Ajith Pande
Greenhorn

Joined: Nov 10, 2003
Posts: 2
Hi,
if you want see name of a employee dynamically then u shud dispaly employee numbers in dropdown list b'coz for toching database some event shud happen.
regards
Ajith
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Actually the list of employees r too long to show in drop down menu.
Is there any other way.?Pls help
Balan Raj
Ranch Hand

Joined: Aug 26, 2003
Posts: 74
Show a text field for emp id & disabled list box for emp name initially. Once the user tabs out of the text field or hits the enter key, handle the event and submit the page. The submission of the form, should make the necessary DB hit to get the appropriate (or related set ) of emp names.
If there is too much data, I don't see the list box as an option..
hope this helps..
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Can u pls tell me with code...like i have been trying to do this since long without any result.
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
hai,
for this i think u can do like this.
u call a function on onblur event of a textbox and there u submit the form.
something similar to
<input name=text onblur="call();">
in the call function u can submit the form.
hope this helps
jyothsna
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
I am not able to do it since in the function i need to get connected to database to get the emp name.Than how to connect from jsp to javascript fnction and than connect to database in javascript?
so pls give soln in jsp..?
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
u can do like this.
create a function which u want to call on onblur event like this
<script language="javascript">
function call()
{
---
-----
}
</script>
here u write the necessary code.
or u can submit the form and do the things related to the database and then come back to the jsp page and display the results.
still have problems,ask me
jyothsna
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399

This is quite raw, you can do in more cleaner way.
Now in the html you can do something like this...

hth
MB
ps. do chk out for the proper javascript statment to submit the form & to diable a form element, am not quite sure abt them.
[ November 11, 2003: Message edited by: Malhar Barai ]

Malhar Barai
SOA & Java Book
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
This is what i really want...
There r many fields in the form ...the first 2 are emp no and emp name...in jsp page!!
Now when the user enters the no in the first field...the emp name of that particular employee should be displayed fetching from the database.
 
Don't get me started about those stupid light bulbs.
 
subject: Form in Jsp