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



Home Answers Viewqa Ajax DropDown and text boxes with AJAX, JSP
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sona
DropDown and text boxes with AJAX, JSP
1 Answer(s)      4 years and 4 months ago
Posted in : Ajax


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 rev number for textboxes in the Add employee Form. when the user entered values in the text boxes onblur it needs to validate whether the inserted values are already present in another table.The Validations need to verify that emp no should be unique and it can?t be duplicated, if the emp number is duplicate mean that emp number already exists, in that case it should not allow the user to add a new employee details with same emp number.it needs to alert emp no is already present.

we are already using jsp's and java technology. can we integrate ajax in jsp's to achieve the same? if so could you please guide me to achive the same with sample code

Thanks in advance for ur help.

regards
sona

Advertisement
View Answers

August 27, 2010 at 4:21 PM


Hi Friend,

Try the following code:

1)checkEmployee.jsp:

<html>
<head>
<script>
var xmlHttp;
function showState(str){
if(typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert ("Browser does not support XMLHTTP Request")
return
}
var url= "emp.jsp";
url += "?val=" +str;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function stateChange(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
var v=xmlHttp.responseText;
alert(v);
}
}
</script>
</head>
<body>

<table>
<tr><td>Enter EMP ID:</td><td><input type="text" id="txt" onkeyup="showState(this.value)"> </td></tr>
<tr><td>Enter Name:</td><td><input type="text" id="txt1"></td></tr>
</table>
</body>
</html>

2)emp.jsp:

<%@page language="java" import ="java.sql.*" %>
<%

String val = request.getParameter("val").toString();
String data="";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( "SELECT * FROM employee WHERE empid='"+val+"'");
String id="";
while(rs.next()){
id=rs.getString(1);
}
if(id.equals(val)){
data="Emp No is already present!";
response.getWriter().println(data);
}
else{
data="This is valid id";
response.getWriter().println(data);

}


%>

Hope that it will be helpful for you.
Thanks


Related Tutorials/Questions & Answers:
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... in the text boxes onblur it needs to validate whether the inserted values
DropDown in ajax+jsp
DropDown in ajax+jsp  I have four dropdown if i select first dd...; <head> <script language="javascript" type="text/javascript">... dropdown. You can create the fourth one similarly. For the above code, we have
Advertisements
Ajax Dropdown
Ajax Dropdown  hi I have One Dropdown that contains 2 options assume A and B,if i select A option then samepage one more Dropdown is their it should display values in german language using DWRUtil Parameter values in ajax. Only
ajax+dropdown+table format
ajax+dropdown+table format  HI, i am looking for an ajax application which must contain two dropdown list.In first dropdown if i select a manager name from the first dropdown all the reporties under the selected manager should
dropdown list and text fields in php
dropdown list and text fields in php  How could I use php to populate text fields by selecting a name of a business from dropdown list? Those text fields that will be populated by information in regards its company name, suite
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
Multiple select dropdown with Ajax
Multiple select dropdown with Ajax This tutorial explains how to create multiple select  dropdown with Ajax  in JSP and Servlet . This example... database if not exists `multipleselect_dropdown`; USE `multipleselect
dropdown - JSP-Servlet
dropdown  i want to use dropdown select value in query-string in same..... without using Ajax...  Hi Friend, Try the following code... = document.form.sel.options[w].text; window.location.replace("select.jsp?st="+value
dropdown list in jsp
dropdown list in jsp  hai, i have static dropdown list.. i want to get the selected value in string variable without jsp regards asha
jsp dropdown - JSP-Servlet
jsp dropdown  in my table there are 3 fields named orderid ,itemname, itemqty. i want code that fetch orderid in dropdown... on select dropdown get all items list of that orderid... there are multiple items at one orderid
jsp dropdown - JSP-Servlet
jsp dropdown  print dropdown selected value in same page without refreshing page in jsp....   Hi Friend, Try the following code: 1)selectbox.jsp: var xmlHttp function showState(str
Ajax with jsp - Ajax
Ajax with jsp  multiple combo boxes with ajax in jsp?  Hi friend, I am sending you a link. I hope that, this link will help you. Please visit for more information. http://www.roseindia.net/jsp
checkbox with dropdown listbox in jsp
checkbox with dropdown listbox in jsp  i loaded the the data into the drop down listbox in jsp from access database.now i have to add a check box,if it checked means dropdownlist box carryout the data's,else it should
values of Combo boxes are not stored in database - JSP-Servlet
values of Combo boxes are not stored in database   i have some combo box values. when i click the submit button after select combo box values...(class_name){ var val = class_name.options[class_name.selectedIndex].text; if((val
dropdown - JSP-Servlet
dropdown  i have below code for dropdown . now i want to user that textbox value in query at same page... how to get it in a new variable... = combo.options[combo.selectedIndex].text document.getElementById('val').value=val
creating dropdown lists in jsp
creating dropdown lists in jsp  i want to create two dropdown list which are dependent that is the first box choice have to evaluate the second boxs options
jsp dropdown refresh - JSP-Servlet
jsp dropdown refresh  Sir Thank u for your jsp code for dependent dropdown list, i used it in different table for data extraction but the probleam during data extraction when i select first drop down its refresh then 2nd
using jsp's....and ajax - Ajax
using jsp's....and ajax  Hi, i need code using ajax .....in a text box when i enter an alphabet i should get list of words starts with the alphabet given in the text box
auto complete text box - Ajax
auto complete text box  How to create auto complete text box in jsp using ajax technology ? plz giv me steps wise code
dropdown - JSP-Servlet
dropdown  i want to use dropdown select value in query-string in same page.. Using selected 'name' want to fetch details of that person from database..  Hi Friend, Try the following code: 1)ajaxExample.jsp
how to dynamically add text boxes with add and remove link based on drop down choices, if a particular choice is selected.
how to dynamically add text boxes with add and remove link based on drop down choices, if a particular choice is selected.  how to dynamically add text boxes with add and remove link based on drop down choices, if a particular
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
jsp- database dependent dropdown list
jsp- database dependent dropdown list   i want 2 dropdown list 1... suppose class a the corresponding section dropdown list should retrieve the section respective to that class from database. please help by providing the code in jsp
To display suggestions in a text box - Ajax
the Ajax : Some steps to be memeber : 1)Create a text box on the JSP Page. 2)On this text box call a function onKeyUp event using Ajax. 3)Pass the value... visit to : http://roseindia.net/ajax/ http://www.roseindia.net/jsp
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  http://www.roseindia.net/answers/viewqa/Ajax/15250-DropDown-in-ajax+jsp.html Thank you for this program, it helped me alot to learn. I have done it. now i want
3 dropdown list from the database using JSP
3 dropdown list from the database using JSP  Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
jsp & ajax
jsp & ajax  how to enable or disable textbox using radio buttons by using jsp and ajax? plz help me.... i m new in jsp & ajax
ajax code with jsp - Ajax
ajax code with jsp  hi , Sorry for insufficient data.i m making some correction on question. I have to perform some calculation on my jsp page. i want to do it automatically (using ajax in jsp). problem is - i hv two
jsp and ajax
jsp and ajax  how to enable or disable textbox using radio buttons by using jsp and ajax
ajax jsp - Ajax
ajax jsp  multiple combo with ajax using jsp?  Hi friend, I am sending you a link. This link will help you. Please visit for more information. http://www.roseindia.net/jsp/comboSelect.shtml Thanks
ajax and jsp code - Ajax
ajax and jsp code  can u please give me the code for retriving the data from database using ajax our requriment is if i select country name in listbox display the corresponding all the states. using jsp and ajax   
Advertisements
 

 

 

DMCA.com