3

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...

2
  • 2
    AJAX seems like the logical thing to use here.
    – Milo
    May 3, 2011 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, 2011 at 14:49

1 Answer 1

2

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 http://s.wordpress.org/extend/plugins/search-autocomplete/screenshot-1.gif?r=380767

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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