Repeated textbox 'autofill' to be inserted to textbox for submission

Hi,
Background to my question…
my textbox wll have a placeholder of ‘Enter ingredients, dish names or meal type’ (for example), and when typed into, the form will send off by ajax, to a php script that will query the db for results that match whats been typed into the textbox - probably from when I enter the 3rd character.

I want the results to display beneath the textbox so I can click on one of them to put it into the textbox eg typing car will give a list of carraway seeds, carrots, cardamon pods and suchlike.

Next, I want to click on carrots (in the dropdown of returned results) and for that word to be entered into the textbox where ajax will fire off to the php query script.

After that is done, I may enter ‘bea’ and when I click one of the results listed beneath textbox, - beans, baked beans, beansprouts etc I want that selection to be added to whatever is already in the textbox. So then we get carrots, beans

As I click on ‘beans’ to put it into the textbox (alongside carrrots), I want ajax to fire again and to query the db for both carrots and beans so the resultset will include dishes with either carrots or beans in them.

I haven’t been able yet to identify effective search terms so progress is verrrry slow.
I’m initially asking for search terms so I can try to find something I can work on.

I’d also like to have clarified, whether I am asking for two types of query - because I think I am.
Q1 would search for items that match whats been typed into the textbox as it is being typed.
Q2 would search for items that match all that has been entered from selections, into the textbox possibly when I click to add an item to the textbox.

Also, would the list of carrots,beans actually be in the textbox or would that be a visual perception? I have seen something similar in real estate sites for looking up several areas but I don’t want to plagerize their work.

Any assistance you may offer, would be very welcome.

Bazz

So you’re trying to do something like the Google autocomplete in the search box? Every few characters, look up the partly-completed word and display some results? Does ‘autocomplete’ as a search term help finding anything?

You might be better asking in the JavaScript are of the forum, as the PHP aspects of this are quite trivial - that bit is just doing the word-search and returning the results. Deciding when to call it, and what to parse out of the text box to do the search is (to me) the more complex bit.

Thanks,

I’ll mull over some more because in two separate scripts, I have the autocomplete part working in one of them and in another - my previous project - I can use ajax to populate the main body of the page with the full resultset of dishes/recipes containing ‘carrots, peas’. I think its the manner of how to call the ajax query for the main body that I need to work out - and that is probably javascript.

Thanks again.

OK, I’ll start a new thread in the javascript forum so please consider this thread closed. :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.