I’m creating my own recipe box using php/mysql and one part I’m stuck on is actually creating the recipes, specifically selecting the ingredients.
What I wanted to do instead is have a auto-complete search box where I can type out names of the ingredients, have the results drop down right below, and click the ones I’m looking for. After clicking the ingredient, it’ll be listed below the search box with an input to put quantity and an “x” to delete if needed. This of course would grow depending on how many ingredients the recipe requires. At the end, I would just take the data and do an insert into my database.
I’ve seen a lot of AJAX tutorials on getting the auto-complete search box functionality, but nothing tying it to the value selection. The best example of what I’m going for can be found at http://supercook.com. They have it so you can search for recipes.
Any suggestions or online resources?
Thanks!
you asked a great question. Below I’ve written a short example to get you started. Just save it as ingredients.php and it should work. Of course, you’ll need to add your database connection and query to give it real data. I’ve used the jQuery library because it makes the Javascript part a lot easier.