Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am new to wordpress, so if this question was already answered I apologize in advance.

I have a search form in wordpress which looks like this:

<form action="wordpress/action.php" id="search_form" method="get">
<label for="s" class="hidden"></label>
<input type="text" size="30" id="s" name="s" value="">
<input type="submit" value="Search" id="searchsubmit">
</form>

The file action.php looks up a given string (in this case a name) in a database and returns an array of "similar" written names. After hitting the submit button I want the results to be proposed in a clickable proper list to the user. I thought of listing the items in the same widget. Here the structure I was thinking of.

SEARCH FIELD HERE | SUBMIT BUTTON HERE

John Doe
John Dö
Johnny Doe
etc.

Then the user can click the prefered name and information to this name will be shown in the main part of the page.

Is there something that already realizes that? Or do I have to write that on my own. In the second cas: What would be the best approach for that?

Update

I was thinking about using sessions to store the result of a query of a user. Redirecting to the same page would let php read the list and print it to the widget. Would this be a usable approach? Well, I still need to know where to tell php to echo inside the text widget, though...

share|improve this question
2  
AJAX seems like the logical thing to use here. –  Milo May 3 '11 at 14:23
1  
I once wrote an answer on how to handle submit forms in widgets, with three possible approaches. I would also do this with AJAX to return the results. You don't need sessions, you have the query in the request. –  Jan Fabry May 4 '11 at 14:49
add comment

1 Answer

up vote 2 down vote accepted

While looking for possible pointers I found the SearchAutocomplete plugin, which seems to do what you want. You can see it in action at the site of the author.

Search box with autocomplete dropdown in different themes

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.