How do I autofill a textbox with data coming from php, not saved by a cookie and not in autocomplete in jQuery?
For example : If I type ‘P’ in textbox ,then corresponding data ‘Prince’ is taken from php must be auto filled in textbox with only ‘P’ in black color and other ‘rince’ will be faded.
Here the cursor will be in after ‘P’ and before ‘rince’. If I move the cursor to right corresponding data ‘Prince’ will needed to be black color. If I typed second letter that is ‘Po’ then new corresponding data ‘Pond’ will be autofilled.
Here’s a solution that I’m using on a site I am currently developing. This particular solution is basic and could be extended further.
The idea is to create a ‘clone’ input, which we place underneath the original input field. We then give the original input a transparent background so that any suggestions from the clone can be seen underneath.
For the sake of speed, it’s best to have the data set in Javascript array, or object, which could be set when the page loads using AJAX.
http://jsfiddle.net/2AkmG/