After searching quite a bit, I've found this script over here:
Must say I'm impressed, it worked perfectly
But then I wanted to make a second field to use it with, as is explained in the text should possible;
The ajax_showOptions function takes two arguments. The first one should always be this, i.e. a reference to the text field. The second one is just a string that is sent to the file on the server. This is useful in case you are applying this feature to more than one text field. If you do, this string is something you could check on on the server(example: if "getCountriesByLetters" is set, find countries, if "getStatesByLetters" is set, get states etc.).
This on the other hand, did not go so well.
The situation;
I've made two input fields.
In one, the function is being called like this:
onkeyup="ajax_showOptions(this, 'getArtistsByLetters');"
In the other, the function is being called like this:
onkeyup="ajax_showOptions(this, 'getAlbumsByLetters');"
This page you can see here:
http://209.124.83.52/x/x.php
(I stripped away all things that are irrelevant atm.)
Here is what my file looks like that pulls the info from the DB, and the change made to the .js file:
http://209.124.83.52/x/explained.php
The issue;
The problem is, that if you enter the letter "b" into the first field, you get a nice list of artists.
If you now enter the letter "b" into the second field, you get that exact same list of artists, instead of a list of albums.
If you reload the page, and enter the letter "b" into the second field, you get a nice list of albums.
If you now enter the letter "b" into the first field, you get that exact same list of albums, instead of a list of artists.
Is the list somehow being saved and re-used?
If someone knows how to overcome this, it would be greatly appreciated.
Thanks you,
- Abra