So I want to use this plugin
I want to retrieve all the user names from database using codeigniter then store them in a var in javascript (If this is a good way) then use it in autoplete. Also, I want the user if he/she enters any other text it wont be accepted, it has to be already stored in database only.
Thanx in advanced :)
So I want to use this plugin http://docs.jquery./Plugins/autoplete
I want to retrieve all the user names from database using codeigniter then store them in a var in javascript (If this is a good way) then use it in autoplete. Also, I want the user if he/she enters any other text it wont be accepted, it has to be already stored in database only.
Thanx in advanced :)
Share Improve this question asked Mar 30, 2011 at 14:42 KayKay 2133 gold badges10 silver badges18 bronze badges 2- 3 Are you wanting us to write the code for you? Are you having trouble with something in particular? How about you give it a shot, and we'll help you along the way? – Jesse Bunch Commented Mar 30, 2011 at 14:44
- I tried to do it, but I dont understand how to use a database with it. If its a simple var then OK, but getting from database is a bit difficult for me, I didn't entirely understand how to do it. – Kay Commented Mar 30, 2011 at 14:46
1 Answer
Reset to default 4OK, Here is how I would structure it:
First, you have to create a file to serve your data from your backend database. According to the jQuery Autoplete Docs, your backend will need to return a list of options one per line.
Let's call our php file, get_results.php:
<?php
// Do your DB calls here to fill an array of results
$arrResults = array('option 1', 'option 2', 'option 3');
// Print them out, one per line
echo implode("\n", $arrResults);
Then, in your JavaScript code, you'd do something like this:
$("#myTextBox").autoplete('get_results.php');
That is the very basic of how I would do it. Hopefully, you can go from there. Here are some important resources:
- PHP Basics
- PHP Database Connections
- jQuery Autoplete Docs
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744990056a4604848.html
评论列表(0条)