Dynamically adding textbox and labels

Ads
 

Dynamically adding textbox and labels

Sir, In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label. Plz help me, Thanks in advance.

View Answers

March 14, 2011 at 5:33 PM

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; 
    document.getElementById("lab").innerHTML="Address";
    document.getElementById("address").style.visibility="visible";
    document.getElementById("address").value= showdata;
        } 
}
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>
<pre>
<label>Name</label>     <input  type="text" name="name" id="name" onkeyup="showData(this.value);">
<label id="lab">       </label>  <input style="visibility:hidden" type="text" name="address" id="address">
</form>    
</html>

2)getdata.jsp:

<%@ page import="java.sql.*" %> 
<%
String name = request.getParameter("name").toString();
System.out.println(name);
String data ="";
try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee where name='"+name+"'");
while(rs.next())
{
data =rs.getString("address");
}
out.println(data);
System.out.println(data);
}
catch (Exception e) {
System.out.println(e);
}
%>

Ads









Related Tutorials/Questions & Answers:
Dynamically adding textbox and labels
Dynamically adding textbox and labels  Sir, In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label. Plz help me, Thanks in advance
having difficulties in dynamically adding textbox with datepicker
having difficulties in dynamically adding textbox with datepicker  hi... add new row of textbox. And also able to use datepicker for the textbox as well. However, I am able to add and display the textbox but not the datepicker. I
Advertisements
jtable-adding a row dynamically
jtable-adding a row dynamically  hi..i am doing a project for pharmacy .. *pblm:* when i want to enter the details in jtable while running... to add one more row dynamically as a new row 4th if the details are large.but every
Dynamically hide textbox
Dynamically hide textbox  I have a drop down(combo box) with 2 values (reference and file).When refrence is selected from the drop down the components of file(that is displayed when file is selected) should get hidden dynamically
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown... with two text boxes. if I type something in one textbox, the corresponding value... in another textbox. How can I achieve
How to display gridview details to labels dynamically?
How to display gridview details to labels dynamically?  I am using SQLDataSource to connect to MySQL. I have a gridview that retrieves information... the gridview results on labels. I used lbDate.Text = GridView1.Rows(0).Cells(0).Text
how to get the values from dynamically generated textbox in java?
how to get the values from dynamically generated textbox in java?  I... textbox corresponding to the data. I want to get data from textboxes(generated as per the retrieved data) and I want to store textbox values into the two table
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
ModuleNotFoundError: No module named 'labels'
ModuleNotFoundError: No module named 'labels'  Hi, My Python... 'labels' How to remove the ModuleNotFoundError: No module named 'labels'... to install padas library. You can install labels python with following command
labels,textfields,buttons
labels,textfields,buttons  how to set the labels,textfields,buttons at certain positions such that we can add them without layout managers? my program is to design a login page with image and these labels at exact positions
store dynamic generated textbox value into database
store dynamic generated textbox value into database  sir, how do i store dynamically generated textbox value into the database thanks in advance
Adding an employee
Adding an employee  coding for adding an employee
ModuleNotFoundError: No module named 'chord-labels'
ModuleNotFoundError: No module named 'chord-labels'  Hi, My Python... 'chord-labels' How to remove the ModuleNotFoundError: No module named 'chord-labels' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'chord-labels'
ModuleNotFoundError: No module named 'chord-labels'  Hi, My Python... 'chord-labels' How to remove the ModuleNotFoundError: No module named 'chord-labels' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'crr-labels'
ModuleNotFoundError: No module named 'crr-labels'  Hi, My Python... 'crr-labels' How to remove the ModuleNotFoundError: No module named 'crr-labels' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'unwrap-labels'
ModuleNotFoundError: No module named 'unwrap-labels'  Hi, My... 'unwrap-labels' How to remove the ModuleNotFoundError: No module named 'unwrap-labels' error? Thanks   Hi, In your python
Dyanmically Adding Rows with Date Picker
Dyanmically Adding Rows with Date Picker  Hi Sir, I am doing a project in that i need to add rows dynamically with date picker inside row, send me code as soon as possible. Regards, Santhosh
How to create textbox on combo value selection using javacsript in jsp?
How to create textbox on combo value selection using javacsript in jsp?  dynamically create textbox on combo value selection. when select multiple values then create multiple textboxes
adding a dialogue
adding a dialogue  Blockquote Hi can you help with the program below,the program is a loop that prints out a code and a quantity when prompt for the user input.what I need is to modify the code to incorporate a dialogue asking
adding loop
adding loop  Hi I have a program that is not compiling when I add a loop can you help me?The program below is compiling without the loop. > Blockquote mport java.util.*; import java.text.*; import java.util.Scanner
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
ModuleNotFoundError: No module named 'django-taggit-labels'
ModuleNotFoundError: No module named 'django-taggit-labels'  Hi...: No module named 'django-taggit-labels' How to remove the ModuleNotFoundError: No module named 'django-taggit-labels' error? Thanks   Hi
ModuleNotFoundError: No module named 'sanitize-ml-labels'
ModuleNotFoundError: No module named 'sanitize-ml-labels'  Hi, My... named 'sanitize-ml-labels' How to remove the ModuleNotFoundError: No module named 'sanitize-ml-labels' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-taggit-labels'
ModuleNotFoundError: No module named 'django-taggit-labels'  Hi...: No module named 'django-taggit-labels' How to remove the ModuleNotFoundError: No module named 'django-taggit-labels' error? Thanks   Hi
ModuleNotFoundError: No module named 'docker-auto-labels'
ModuleNotFoundError: No module named 'docker-auto-labels'  Hi, My... named 'docker-auto-labels' How to remove the ModuleNotFoundError: No module named 'docker-auto-labels' error? Thanks   Hi, In your
showing the information of database in textbox
showing the information of database in textbox  how to make a information of a database make appear to the user in the textbox
Getting mysql table in textbox
Getting mysql table in textbox  how to get mysql table values into textbox in java using ajax and servlets
Hibernate :dynamically choosing server
Hibernate :dynamically choosing server   Is it possible to dynamically choose server name in hibernate
Adding two numbers
Adding two numbers  Accepting value ffrom the keyboard and adding two numbers
change xml dynamically
change xml dynamically  How to change an XML dynamically in Java

Ads