Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Ganesh D Ganbote
Text event in jsp
1 Answer(s)      3 years and 8 months ago
Posted in : JavaScript Questions


Hi I am doing project in jsp with mysql as database.My quens is ,in my webform when I enter value (numeric) in 1st textbox then remaing below textbox must be fill with value that coming from database. So for that purpose which textevent should i used. I have to do without button. Please suggest some code.


Advertisement
View Answers

December 13, 2010 at 4:38 PM


Hi Friend,

Try the following code:

1)ajax.jsp:

<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(value){ 
xmlHttp=GetXmlHttpObject()
var url="getdata.jsp"
url=url+"?name="+value
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged() { 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
    var showdata = xmlHttp.responseText; 
    var strar = showdata.split(":");
    document.getElementById("age").value= strar[1];
    document.getElementById("city").value= strar[2];

 } 
}
function GetXmlHttpObject(){
var xmlHttp=null;
try {
  xmlHttp=new XMLHttpRequest();
 }
catch (e) {
 try  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
</script>
</head>
<body>
<form name="employee">
<br><br>
<table >
<div id="mydiv"></div>
   <tr><td><b>Name:</b></td><td> 
 <input  type="text" name="name" id="name" onkeyup="showData(this.value);"></td></tr>
<tr><td ><b>Age:</b></td><td>
<input  type="text" name="age" id="age" ></td></tr>
<tr><td><b>City:</b></td><td>
<input  type="text" name="city" id="city" ></td></tr>
</table>
</form>    
<table border="0" width="100%" align="center">
<br>
<br>
</table>
</body>
</html>

2)getdata.jsp:

<%@ page import="java.sql.*" %> 
<%
String name = request.getParameter("name").toString();
String data ="";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from data where name='"+name+"'");
while(rs.next())
{
data =":"+Integer.toString(rs.getInt("age")) + ":" + rs.getString("city");
}


out.println(data);
}
catch (Exception e) {
System.out.println(e);
}
%>

In the above code, when you enter the name in first field then remaining fields will get populated automatically.

Thanks



Related Tutorials/Questions & Answers:
Text event in jsp
Text event in jsp  Hi I am doing project in jsp with mysql...="text/javascript"> function showData(value){ xmlHttp=GetXmlHttpObject() var url... type="text" name="name" id="name" onkeyup="showData(this.value);"><
Text box control--keypress event
Text box control--keypress event  In my form have a text box...My requirement is... when is type characters in that box... before typing the 3rd character the space should come automatically or programmatically...the sturucture
Advertisements
event handling in jsp
event handling in jsp  i am developing a web application. i am getting a problem in event handing in jsp. in this web application there is a file generic.jsp for this jsp page i am using a database name as "priyadarshaniDB
Validate JTexField with date on Text Changed event - Java Beginners
Validate JTexField with date on Text Changed event  Hello Sir I want to only Validate date in MM/DD/YYYY Format on TextChanged Event,date will automatically set through MM with two digits,then cursor will automatically set
a jsp code for creating a text file
a jsp code for creating a text file  Hello,i need jsp code for creating a new text file for each user, when they login in to the website for creating a new data file. So i need a jsp code for following options. when user login
JSP Text Box properties. - JSP-Servlet
JSP Text Box properties.  How do I restrict a text box created in JSP page only for numbers.. example: I have a function something like... any such in JSP. please let me know how to do it..  Hi Friend, Try
rich text field - JSP-Servlet
rich text field  Hi, this is jawahar. my question i need rich text field in my program . plz send me the code
text to speech code in jsp - Java Magazine
text to speech code in jsp  Is their any code in jsp for text to speech i.e when i enter text in text area and press submit button , the text i entered should come in voice as output
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql database. The image is shown correctly on seperate jsp page but when shown
JSP combo and text field related questio
JSP combo and text field related questio  in JSP,i had stored data from database in a textboxes usin combo..now i want to use these values of text... and name given to that text field..but its showing somethimng null pointer exception
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box  Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values will generate from database table
how to capture IE browser FileDownload box open ,save and cancel event - JSP-Servlet
; I have a JSP page which allows user to download a file.When user click... to capture open,save and cancel event of filedownload box in javascript. Please... : 1.Create a Jsp page having Download Button. File Download
spell cheking in text area - JSP-Servlet
spell cheking in text area   Hi Good Morning. I am developing web application. Now i am in one JSP page. in this page i have 1 text area. i want spell check functionality by pressing right click in this text area.but i don't
event handling
event handling  diff btwn event handling in ASP.net and in HTML
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box - JSP-Servlet  Auto Complete Text Box Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql...].text; window.location.replace("http://localhost:8080/examples/jsp
DropDown and text boxes with AJAX, JSP - Ajax
DropDown and text boxes with AJAX, JSP  Hi, we are using one drop down and two text boxes. Drop down values needs to be retrive from one table.we should provide a text box through which users can input the emp number and emp
Drop-down text selection in jsp/html
Drop-down text selection in jsp/html  Hi, I am trying to create JSP page where I have two drop-downs. There are two-sets of data - First set Categories- Movies, Books, Music and the Second set Genres- Action,Comedy,Romantic
Automatically display in text box - JSP-Servlet
Automatically display in text box  Dear Deepak Sir, When i enter some text in text box.That corresponding value in database,the value display in another text box using ajax. Thanks & Regards, VijayaBabu.M
Display message on scroll Event
Display message on scroll Event In this tutorial, we will discuss about how to display message on scrolling of text area using jQuery scroll event. In this example, a text area with scroll bars are given , when we scroll any one
select option with text facility - JSP-Servlet
select option with text facility  Hello. My doubt is regarding how to provide facility to add text in a drop down box ie(select tag in html )in a jsp...[getdropdown.options.selectedIndex].text = ''; getdropdown.options[getdropdown.options.selectedIndex
Read Text file from Javascript - JSP-Servlet
Read Text file from Javascript  plz send the code How to Retrieve the data from .txt file thru Javascript? And how to find the perticular words in that file
Event management
Event management   Hi, I want event management application like maintaining email notifications while task creation and update in broader way using spring java
Event in flex
Event in flex  Hi..... can you tell me about that How do you make component participate in event mechanism? Thanks   Ans: Extend EventDispatcher or any subclass of it or implement IEventDispatcher
Flex event
Flex event  Hi.... please tell me about How does Flex event system works? Thanks  Ans: When event are triggered there are three...: In the capturing phase, Flex examines an event target?s ancestors in the display list to see
Event in flex
Event in flex  Hi..... I want to know about What does calling preventDefault() on an event do? How is this enforced? please give me an example for that Thanks   Ans: The methods of the Event class can be used
Flex event
Flex event  Hi.... Please tell me about How to create your own event in flex? Thanks
Flex event
Flex event  hi...... How to capture and event if the component is disabled? please give an example..... Thanks in advance
Flex event
Flex event  Hi... please give me the answer with example What is event Bubbling? Thanks in advance  Event Bubbling: In the bubbling phase, Flex examines an event?s ancestors for event listeners. Flex starts
how to restrict user against marking same event more than one times - JSP-Servlet
how to restrict user against marking same event more than one times ... of question which are included under various event type. The result of this test(event) is stored in final database. Now how can I restrict the student against
Event helpers
Event helpers       Event helpers As we all know events are actions or occurrences detected by a program. And event handlers are methods which handles
Insert text into database table using JSP & jQuery
Insert text into database table using JSP & jQuery In this tutorial , the text is inserted into database table using JSP & jQuery. In the below example, the first JSP page is use to display text box in which we type data
Click event
Click event  hi............ how to put a click event on a particular image, so that it can allow to open another form or allow to display result in tabular form????????/ can u tell me how to do that????????/ using java swings
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
Flex event
Flex event  Hi..... How many events are fired when your focus goes in one text box, you enter some text and then press tab? Please give the name of all events which is used in this..... Thanks
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I enter the letter A in the textbox it should show only those values which starts
To Retain the values entered in the text box after submit in jsp page
To Retain the values entered in the text box after submit in jsp page   i am working on a jsp pge which has many text boxes and one dynamic drop down. The functionality is when user enters comma separated values in those text
Upload and display image and text records using JSP and Oracle
Upload and display image and text records using JSP and Oracle  Hi all, I'm using JSP and Oracle 10g. I could retrieve and display records from database. But i couldnot retrieve and display image. I want to store
javascript cal code for selecting date in text field - JSP-Servlet
javascript cal code for selecting date in text field  HI I want javascript calendar code to select date in text field in jsp.pls send me? .../jsp/emp-event.shtml http://www.roseindia.net/javascript/javascript
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using... that dynamically generated text box value into database at a time without
jquery href onclick event
jquery href onclick event  jquery href onclick event   $('a').click(function (event) { event.preventDefault(); //here you can also do all sort of things });   <script type="text/javascript
handling Button Event in iphone
handling Button Event in iphone  handling Button Event in iphone
How to Handle Event Handlers?
How to Handle Event Handlers?  How to Handle Event Handlers
Java event handling
Java event handling  What event results from the clicking of a button
how to create text file from jsp and provide downlode option
how to create text file from jsp and provide downlode option  HI... in java/j2ee tech. my question is who do i make a jsp output in the form of text... this my jsp page <%@ page language="java" contentType="text/html; charset
input type dialog box take text and search a list and focus that text - JSP-Servlet
input type dialog box take text and search a list and focus that text  i have a button..when i press it will prompt a dialog box with a text box... then it will search a list which contains data in the same page and if found
Java event delegation model
Java event delegation model  What is the highest-level event class of the event-delegation model
Java event-listener
Java event-listener  What is the relationship between an event-listener interface and an event-adapter class
To get the value of more than one text box in an HTML page to a jsp page - JSP-Interview Questions
To get the value of more than one text box in an HTML page to a jsp page  An html file has a text box as To get the value of this text box in a JSP... the value of text boxes to a jsp page and how to access the same
 

 

 

DMCA.com