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



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

Have Programming Question? Ask it here!
 
 
 


sona
DropDown and text boxes with AJAX, JSP
1 Answer(s)      3 years and 11 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
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
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
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
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
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
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
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
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
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
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
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
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
jsp and ajax
jsp and ajax  how to enable or disable textbox using radio buttons by using jsp and 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
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
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
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   
jsp - Ajax
jsp  I'm very new in using the jsp and ajax, i have some JSP pages and i need to add some ajax features in my jsp page, for the example i need.... How can I implement this and then add this to my jsp page? please
dropdown
dropdown  how to hide textbox field when i deselect from select dropdown
dropdown box
dropdown box  i need to have country,state and city in drop down box using ajax and use db2 database   Have a look at the following link: JSP dependent dropdown
dropdown vlaue changes based on input given in textbox uisng AJAX
dropdown vlaue changes based on input given in textbox uisng AJAX  hi, In my app i need one textbox based on textbox data, values in dropdown list have to change and dropdown data retreive data from database thanks KK
Jsp and ajax
Jsp and ajax  Hi I am using jsp and ajax.I am retrieving...; function ajax(str){ var xmlHttp; var i; var config=document.getElementById..."; url=url+"?q="+config+"&q1="+config1; xmlHttp.open("POST",url,true
Jsp and ajax
Jsp and ajax  Hi I am using jsp and ajax.I am retrieving...; function ajax(str){ var xmlHttp; var i; var config=document.getElementById..."; url=url+"?q="+config+"&q1="+config1; xmlHttp.open("POST",url,true
Jsp and ajax
Jsp and ajax  Hi I am using jsp and ajax.I am retrieving...; function ajax(str){ var xmlHttp; var i; var config=document.getElementById..."; url=url+"?q="+config+"&q1="+config1; xmlHttp.open("POST",url,true
Jsp and ajax
Jsp and ajax  Hi I am using jsp and ajax.I am retrieving...; function ajax(str){ var xmlHttp; var i; var config=document.getElementById..."; url=url+"?q="+config+"&q1="+config1; xmlHttp.open("POST",url,true
dropdown
dropdown  I have a dropdown having 2 options-"Open"& "closed".When i select "open" option the related rows of data are retrieved from database and same with the other option.My database is Mysql and coding in PHP
to access value of drop down value in beans when dropdown is populated using ajax
to access value of drop down value in beans when dropdown is populated using ajax  i want to access value of dropdown box in beans .. and this drop down was filled using ajax. plz help
jsp -sevlet connecting to database using dropdown
jsp -sevlet connecting to database using dropdown  How can I get my dropdown list from oracle database and then submit it to another table in JSP. I... it to the JSP to populate the options and when an option is submitted, it send
JSP and AJAX very urgent - Ajax
JSP and AJAX very urgent  Hi Team, This is Ragavendran.R.. I have a very basic doubt in AJAX. While Using AJAX, of course, there will be tag involved in JSP page. But in my current project, I am using too many tags
ajax in jsp
ajax in jsp  i m not able to compare string with the responseText...("<html> <head> <meta http-equiv="Content-Type" content="text...; <td>username: <td><input type="text" name="lnm
ajax in jsp
ajax in jsp  i m not able to compare string with the responseText...="Content-Type" content="text/html; charset=UTF-8"> <script>...: <td><input type="text" name="lnm" id="lnm"/>
JSP and AJAX- very urgent - Ajax
JSP and AJAX- very urgent  Respected Sir/Madam, I am.... In Login.html, I am entering the starting letter in a text box and when I click "Get details... from the letter entered in the text box, is present, without reloading the page
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
jsp and ajax - JSP-Servlet
jsp and ajax  i had some problem i want to display the current... to be automatically updated for every second for that i want to make an ajax call.../jsp/fileupload.shtml Thanks
getting and storing dropdown list in database in jsp
getting and storing dropdown list in database in jsp  i have a drop down list to select book from database. i'm able to retrieve dropdown list from database. but unable to store the selected value in database table. please help
ajax
me reg this. thanks KK   Combobox box using Ajax in JSP   i...ajax  HI, In my application using ajax if i type a managername... in a dropdown from database and when i select the empname in dropdwon list and when i click
 

 

 

DMCA.com