473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

auto complete textbox value from input of another texbox

i have a form which includes an id textbox and a name textbox.

how do i implement it when i will input a id which is integer and a corresponding name to that id in the databases automatically inputs in the name textbox as well?

i want to implement it in a oop approach so i have a class which will contain my function to query the database

and a have a form.php
and the action.php

can anybody help me, i've know that this will probably be using ajax or javascript
Dec 2 '11 #1
3 3889
johny10151981
1,059 1GB
you can send an ajax request on key press but, it is better to send an ajax request to server on change.

You simply can do that
1. Send an Ajax request to server with ID as value.
2. Server will reply with name or failure request(id may not exists)
3. on server reply change the the desired text box.
use JQuery, it will make your life easier
Dec 2 '11 #2
can you give me a very simple example on how to do this??pls. im not really familiar yet on how ajax works, i would really appreciate it.
Dec 2 '11 #3
johny10151981
1,059 1GB
Expand|Select|Wrap|Line Numbers
  1.  
  2. <script>
  3.  
  4. function GetName(obj)
  5. {
  6. $.ajax({url: "getName.php", //the php file that will do the query and  give the name
  7. type: 'POST', //the method you would use, not a big deal in some case, can be a huge deal in some case.  
  8. dataType: 'html', 
  9. data: "Id="obj.value, //this is the input you would send 
  10. timeout: 90000, //your browser will give up after the given time(if your server cannot response in the setting time.)
  11. success: function(html){$('#DisplayName').val(html)});//this will tell what will be done in case of success, by success it mean that your php page responded, you can modify your response to failure even if you php page is found. that advance for you
  12. }
  13. </script>
  14. <input type=text onchange='GetName(this)'>
  15. <div id='DisplayName'></DIV>
  16.  
please download and link jQuery.js file. You are a beginner it might be confusing to you...........
Dec 2 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Claudia Fong | last post by:
Hi, I have 2 forms. Form1 has a button which calls form2, but I need to know the value of the form1.textBox1.text. When I show form2, I try to use the code bellow: textBox1.Text =...
0
by: george d lake | last post by:
Hi, Is there a way to have a "Auto Complete" textbox or a "editable" dropdown? Here is my problem. I have a screen that need to have a list of 800+ employees. To be a dropdown, that could be a...
8
by: John | last post by:
Hi, I am developing an application using VB.Net and hope that the textbox can process features which are similar to auto-complete features in Window. For example, when user types "ap" in a...
0
by: Waran | last post by:
I need to create a Auto suggests Textboox like in http://www.google.com/webhp?complete=1&hl=en I have completed this using AJAX.NET for Framework 1.1 . I have some design issues after the data is...
1
by: Melson | last post by:
Hi Can anyone help please. How can I create a Auto complete textbox using C#. Please help. Regards Melson
1
parshupooja
by: parshupooja | last post by:
Hey All, I am working on vb.Net 2.0 Desktop application. Can any one suggest me how to do Autocomplete TextBox? I have 1 dropdown and one textbox dropdown has criteria such as Last Name, First...
1
by: =?Utf-8?B?U2FpbXZw?= | last post by:
Hello Marc Gravell and Machin. Good Day. Why your not using an Instance in the form and yet your using a New Form? Im using it because I want to open a single form only. If Im using a New...
3
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
2
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
2
by: mbalas2 | last post by:
I set the value of Total texbox through javascript, and Total texbox does show the changed value. But when i access the textbox while saving in the db, the value is reset to previous value (value...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.