how to fill up a form automaically from database and print it

how to fill up a form automaically from database and print it

sir,i am designing a medical license website.i need to fillup a license form atuomatically from details stored in database.ex:if there are details of a person like name age etc..,on clicking the name the whole details of that name(like age)should automatically fill up in the form and on cliking print button it shoulg give a print out. i need code for this in jsp .plsss help me sir

View Answers

July 23, 2012 at 1:33 PM

Here is a jsp code where user is allowed to enter any id and display the corresponding data into another textboxes. We jave used Ajax here to display the context on the same page.

1)ajax.jsp:

<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(){ 
xmlHttp=GetXmlHttpObject()
    var id=document.getElementById("id").value;
var url="getdata.jsp";
url=url+"?id="+id;
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(":");
      if(strar.length>1)
         {
        var strname = strar[1];
        document.getElementById("name").value= strar[1];
        document.getElementById("address").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>
<br><br>
<table >
<tr><td>Client ID:</td><td><input type="text" id="id" name="id" onkeyup="showData();"></td></tr>
<tr><td>Name:</td><td><input type="text" id="name" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" id="address" name="address"></td></tr>
</table>
</body>

2)getdata.jsp:

    <%@ page import="java.sql.*" %> 
    <%
    int id = Integer.parseInt(request.getParameter("id"));

     String data=" ";  
     try{
      Class.forName("com.mysql.jdbc.Driver");
               Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
     Statement stmt = con.createStatement();  
     ResultSet rs = stmt.executeQuery("Select * from addclients where clientid  ="+id+"");  
       while(rs.next())
                    {
                        data = ":" + rs.getString("name") + ": " + rs.getString("address");
                    }
                    out.println(data);
      }
     catch(Exception e){
    System.out.println(e);
     }

 %>
</html>









Related Tutorials/Questions & Answers:
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form...)should automatically fill up in the form and on cliking print button it shoulg give
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form...)should automatically fill up in the form and on cliking print button it shoulg give
Advertisements
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form...)should automatically fill up in the form and on cliking print button it shoulg give
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form...)should automatically fill up in the form and on cliking print button it shoulg give
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form...)should automatically fill up in the form and on cliking print button it shoulg give
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form...)should automatically fill up in the form and on cliking print button it shoulg give
Retrieving Data from Database to fill Combo Box
Retrieving Data from Database to fill Combo Box  Sir, I have a JSP Page with a combo box and a label. I have a database that has two fields id and an image. Now I want to fill the combo box with image and on selecting
how to check the radio button automatically depending up on the value of database when editing the form...
how to check the radio button automatically depending up on the value of database when editing the form...  hi...in my application i am editing the form and in that form the data in the database should come but icant be able
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
How to connect to the database to my application if my database is made up in oracle
How to connect to the database to my application if my database is made up in oracle   How to connect to the database to my application if my database is made up in oracle
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details... from form and stores it in User--%> String Pword = request.getParameter
how to genrate login id and password after submitting the sign up form?
how to genrate login id and password after submitting the sign up form?  i m working on a online voting project in that i have a user sign up form so i want 2 knw that after user submit all the details i that sign up form than
Retrieve value of radio button from database to form
Retrieve value of radio button from database to form  var gn=document.getElementsByName("empg"); //empg is name of radio input type. for(var i=0;i
How to pretty print XML from Java?
How to pretty print XML from Java?  How to pretty print XML from Java
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Browser database. what code will i do? this is my existing code from my
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Browser database. what code will i do? this is my existing code from my
How to connect to database to my application if the database is made up in oracle
How to connect to database to my application if the database is made up in oracle  How to connect to database to my application if the database is made up in oracle   Hi Friend, Follow these steps:ADS_TO_REPLACE_1 1
how to print from right to left in java????
how to print from right to left in java????   can anyone pls tell how to print from right to left in java
Print Form - Java Beginners
Print Form  Hello Sir I have Created Admission Form when user fills data and submit that data to access database,then when i Click on PRINT Button I want to get Print of that forms Contents,How I can Do it with JAVA SWING,plz
print form information when click on print button
print form information when click on print button   Sir,I desingn... please help for printing form information by clickin print button after submit data in the database
swings:how to link from one form to another form
swings:how to link from one form to another form  how to link from one form to another form
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
How to retrieve image from database
How to retrieve image from database  hi........ How to retrieve image from database when it is stored. I have stored image in postgresql and want to retrieve in java form. Can u tel me hw to do? I am trying n able to do also
How to access the database from JSP?
How to access the database from JSP?  Hi, What is the process of accessing the database from JSP page? Thanks   Hi, In the JSP program... database from JSP which explains you how to access the database by embedding
print the multiplication table up to one
print the multiplication table up to one  My problem is that I have to change the code so that the user can tell the program which factor that should...; System.out.println("Enter an integer to print it's multiplication table
How to check if ZooKeeper is running or up from command prompt
How to check if ZooKeeper is running or up from command prompt  Hi, I want to see if the ZooKeeper is running or not on my Hadoop cluster. How to check if ZooKeeper is running or up from command prompt? Thanks   Hi
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
how to display records from database
how to display records from database  I want to display records from database in tables, the database is having 2000 records and i want to display 20 records at a time and to use next and previous link buttons to show
Displaying Database information on the browser.
of PHPMyAdmin) Up to now, we learned how to create database and insert information in the database. In this tutorial, I will show you how to insert the information...;ADS_TO_REPLACE_29 In the above code, I connect the form with the database
How to fill double array in java
How to fill double array in java  how to fill double array in java
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int... of various rows from database in labels by clicking previous and next
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int... of various rows from database in labels by clicking previous and next
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
How to save form fields into the MySql Database without submit button in jsp?
How to save form fields into the MySql Database without submit button in jsp?  I want to store user inputs into the database using javasccript or ajax or jqury but without submit button. Form Contains three fields
how to print crystal report from java - Java Beginners
how to print crystal report from java  I want to know -way to print crystal report from java? -which jar are needed to import? I am new at java... by separating data connectivity and presentation from core application code
How to delete the row from the Database by using servlet
How to delete the row from the Database by using servlet  Dear Sir... then the user data to be delete from the database table. Assume in Database table have...: Delete row from database using servlet   In that link solution
How to retrieve image from database in Servlet?
How to retrieve image from database in Servlet?  Hi, How to retrieve image from database in Servlet? Thanks   Hi, Please check the tutorial Retrieve image from database using Servlet. Thanks
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP same codes for learning to get image which is stored in MySQL Database. How to retrieve image from mysql database in JSP? Thanks   Hi, You can write
How to retrieve and display image from database in Java?
How to retrieve and display image from database in Java?  Hi, I am writing a web application for reading the data from database and displaying.... Please check the it at How to store and retrieve image from database in JSP
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one... and retrieve image from database in JSP? Thanks   HI, You can use... the image. Check this example: Retrieve image from database using Servlet. Thanks
how to use bean to retrieve data from database
how to use bean to retrieve data from database  how to use bean to retrieve data from database   poda sendru
JSP Ajax Form
Ajax Form Example This example explains you how to develop a form that populates dynamically from the database though Ajax call. When user selects employee id from the combo box then the corresponding employee details are populated
how to select the row value that was retrived from the database ?
how to select the row value that was retrived from the database ?  I am getting the data's from the table that was stored in database. Now in the page in which i am getting all the data from the database has an another select
how to select the row value that was retrived from the database ?
how to select the row value that was retrived from the database ?  I am getting the data's from the table that was stored in database. Now in the page in which i am getting all the data from the database has an another select
How to access (MySQL)database from J2ME?
How to access (MySQL)database from J2ME?  I am new to J2ME. I am using NetBeans. Can anyone help me? How to access (MySQL)database from J2ME? ( I search a lot I found that there is need to access database through servlet
how to print data(From databse Oracle10g) in preformatted A4 and A3 paper using jsp
how to print data(From databse Oracle10g) in preformatted A4 and A3 paper using jsp  how to print data(From databse Oracle10g) in preformatted A4 and A3 paper using jsp. I am inserting analysis report into a database using

Ads