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



Home Answers Viewqa Ajax To display suggestions in a text box

Have Programming Question? Ask it here!
 
 
 


naveen
To display suggestions in a text box
3 Answer(s)      5 years and 11 months ago
Posted in : Ajax



Advertisement
View Answers

October 13, 2008 at 3:55 PM


Hi friend,


This can be done by using 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 of Keyword to process page Using Ajax.
4)After getting the response you display all the result corressponding
to the keyword.

For more information on Ajax visit to :

http://roseindia.net/ajax/

http://www.roseindia.net/jsp/comboSelect.shtml

http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml

Thanks




October 13, 2008 at 4:59 PM


follow the steps for getting full source code.

1) Go to flazx.com, Search for Ajax Book
2) Download Book "Ajax on Java"
3) Open the Book and find the below content.
chapter 5
===========
+ Section 5.2
--------------
++ Example 5.4
..................

Rajanikant


October 13, 2008 at 6:13 PM


The code which i am using for my requirement is:

(Here, i am using the static content, i.e, not using database code.)


Sample.html
------------

<html>
<head>
<title>Sample</title>
<head>
<script type="text/javascript" language="javascript">

var xmlHttp;
function showHint(str)
{
if (str.length==0)
{
document.getElementById("txt1").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="gethint.jsp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txt1").value=xmlHttp.responseText;
}
}
</script>
</head>
<body>
<form>
First Name:<input type="text" id="txt1" name="put" onkeyup="showHint(this.value)">
</form>
</body>
</html>


gethint.jsp
------------

<html>
<head>
<title>
gethints</title>
<body>
<%
String a[]=
{
"Anna",
"Brittany",
"Cinderella",
"Diana",
"Eva",
"Fiona",
"Far",
"Gunda",
"Hege",
"Inga",
"Johanna",
"Kitty",
"Linda",
"Nina",
"Ophelia",
"Petunia",
"Amanda",
"Raquel",
"Cindy",
"Doris",
"Eve",
"Evita",
"Sunniva",
"Tove",
"Unni",
"Violet",
"Liza",
"Elizabeth",
"Ellen",
"Wenche",
"Vicky"
};
String q=request.getParameter("q");
String hint="";

if(q!=null)
{
for(int i=0;i<a.length;i++)
{
if(a[i].toUpperCase().startsWith(q.toUpperCase()))
{
hint=hint+""+a[i];
}
}
}
else{
hint="";
}
if(hint==null||hint.length()==0)
response.getWriter().write("no Suggestion");
else{
response.getWriter().write(hint);
}

%>
</body>
</html>



Output i am getting is:

First Name: f

Result is:

First Name: FionaFar<html><head><title>gethints</title><body></body></html>

The result which i am getting is wrong.

It has to display:
First Name: Fiona
Far

Then, i have to select only one.

Please correct me, if i did any mistake.

Thanks and Regards,
Naveen.



Related Tutorials/Questions & Answers:
To display suggestions in a text box - Ajax
To display suggestions in a text box  Hi All, I have a requirement, to get the suggestions i mean when i enter the alphabet in a text box(For ex:'A'), the names that starts from 'A' have to display in the text box
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
Advertisements
how to display webservice response in a text box
how to display webservice response in a text box  Hallo, i have created a webservice and when i sended request to my webservice its sending proper response . the point is how to dispaly the response values in a text box usinj
Display two alert box alternately by clicking on text
Display two alert box alternately by clicking on text In this tutorial , we will discuss about how to display two alert box alternately by clicking on text line. In this example, a text line is given ,when we click
display diffrence between two dates in a text box - JSP-Servlet
display diffrence between two dates in a text box  i have these set of codes // String di=request.getParameter("timestamp2"); String d2... the days in another text box when i click inside that test box.lease help me
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes...="row">Reference GPC</th> 113: <td><input type="text" name
Display current date in text box in JSP using javascript
Display current date in text box in JSP using javascript In this section you will learn how to display current date in text box using JavaScript.For...; Today's Date is: <input type="text" id="datetext"> <
Simple Text display
to display any text in a text input box using a button click. It is very simple... Simple Text display     ... that flex panel we have to use a button and a textinput box which are present
select box and text box validations
select box and text box validations  hi, any one please tell me how to set validations for select box and text boxes using bean classes? thank you   Please visit the following link: http://www.roseindia.net/jsp/user
Text box Checking
Text box Checking  I want to Write only the word A-Z in a text box What is the code
two text box problem
two text box problem  i have two text box in two different pages and same variable use in two text box when enter value in first text box it's reflection show in second text box , how i reduce it in jsf ?   Hi Friend
java script text box
will click submit button the text should be submitted(it shows the value in alert). i also want the text box should generate in front of NEW button(next/prev...java script text box  hi, I created a button when i click
enable text box
enable text box  Dear all I would like to enable a textbox by clicking on a button. pleas ehelp me out how can i do this regards JV
enable text box and label on selection
enable text box and label on selection  hello, Please tell me how to enable label and text box on selection of drop down list box. in drop down list box all values come from database. please reply
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
Fancy Box plug-in for text, portal & swf file
Fancy Box plug-in for text, portal & swf file In this section, you will learn how to display text, portal & swf file inside fancy box by clicking... click on any link like text, portal & swf file, the output will be open
Drag a Text Box into dynamic positions
Drag a Text Box into dynamic positions  Plz can anyone tell how can i drag a text box using mouse or arrow keys... Im doing a accounts projects and i need this feature for cheque configuration
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
J2ME Text Box Example
J2ME Text Box Example       This application illustrates how to create the text box using TextBox class. The TextBox class is a Screen that allows the user to enter and edit text
how to create a text box using awt
how to create a text box using awt  give an example how creat multi buttons & text boxes
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
Name Display in alert box - JSP-Servlet
Name Display in alert box  Dear Sir, Please any one help me......... when i enter some value in text that value is already in database display the alert box but the value is not in data base alert box is not display
create text box by clicking button and submittong text in text box using submit
create text box by clicking button and submittong text in text box using... is created. and i want to do that when i enter the text input in text box and when i... box in SOP). i also want the text box should generate in front of NEW button
How to assign a default value to text box in netbeans
How to assign a default value to text box in netbeans  I have a java application,and i want to assign a default variable to the textbox
display from select box - JSP-Servlet
display from select box  I am doing a jsp project. In this jsp project i have to show the photos in one cell depending on the selection from other selection box which is in the same page. The photos are stored
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 this in actionscript UserID_txt.restrict = "0-9abc^d-zA-Z~!@#$%^&*()+_-'.,"; Do i have
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
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
Change background color of text box - Java Beginners
Change background color of text box  Hi how can i change the background color to red of Javascript text box when ever user enters an incorrect value while on entering a correct value its background color should change green
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...").selectedIndex; var val = document.getElementById("book").options[cid].text
Program to read the text from a file and display it on a JFrame.
Program to read the text from a file and display it on a JFrame.  import javax.swing.*; import java.io.*; import java.lang.*; import java.awt.... a "}"). Any suggestions ?   Use append() method instead of setText(). Here
regarding out put display in html text field
regarding out put display in html text field  how to dispaly the output coming from servlet in a particular text field of html
List the names of classes used to create button and text box in Java.
List the names of classes used to create button and text box in Java.  List the names of classes used to create button and text box in Java
how to display(update) current date and month in select box on selecting the year.
how to display(update) current date and month in select box on selecting the year.  how to display(update) current date and month in select box on selecting the year
how to sort the text file and display it in jtable
how to sort the text file and display it in jtable   my text file is: contig00001 length=586 numreads=4... ctgaggactcctcg i want to display the lines started with ">" symbol to be displayed
radio button selection should move the control to a text box that needs to be complete
radio button selection should move the control to a text box that needs to be complete  on selection of a radio button mouse should move to a particular text box that needs to be filled. How
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
Text box size varying in IE 7 but ok in firefox - Java Beginners
Text box size varying in IE 7 but ok in firefox  I have problem with the size of text field which varies in IE 7 only but its fixed in Firefox( I... box size and placed in td with same width ,STill the first text box grows
instead of text boxe i have to show check box as selected.
instead of text boxe i have to show check box as selected.  i have one text field. in that iam getting boolean value either true or false from the database. when ever the valsue is there in textfield, instead of text boxe i
retrieve value from db in text box + calendar implementation.
retrieve value from db in text box + calendar implementation.  I... there is already a text box..Now i want to get the value retrieved from database in that text field how can i do it... Please help...   Please visit
JDialog to create a customized dialog box for entering text data
JDialog to create a customized dialog box for entering text data   ... dialog box for entering text data. The dialog can be split into panes, left pane can contain an image file and the right pane will contain multiple text fields
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
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
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking the value of combo box . I am not getting it plz help me out .   hi
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
form text box connection with mysql database feild - JDBC
form text box connection with mysql database feild  Respected Sir, What is the coding to connect a form text box field with mysql database table field will you explain me with simple example.. thanking you.. 
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
Display values in textbox on selecting checkbox
Display values in textbox on selecting checkbox Here we are going to perform action on selecting the checkbox and display the first five text box values into next five. We have ten text boxes and a checkbox. As the user enters value
How to Validate dynamically created text box in HTML using Javascript
How to Validate dynamically created text box in HTML using Javascript  Here is the HTML code to create text boxes dynamically. It works properly.... And also how to validate the text boxes created dynamically. <html>
Advertisements
 

 

 

DMCA.com