php中jQuery插件autocomplate的簡單使用筆記
Jun 13, 2016 pm 12:00 PM
首先需要的文件有jquery.js,jquery.autocomplete.js,jquery.autocomplete.js,這三個文件,哪里有?百度、谷歌都可以找到??梢匀ス倬W(wǎng)上下,里面包含了一些demo,只留下這三個文件即可。
js代碼:
復(fù)制代碼 代碼如下:
HTML代碼中只有:
下面是php代碼:
復(fù)制代碼 代碼如下:
if($_GET['action'] == 'getAjaxInfo'){
//這里由于我寫其它應(yīng)用了,如果單純做這一個自動完成,可以寫簡單一點(diǎn)
if($_GET['name'] != ''){
$field = 'name';
}
if($field != ''){
$val = $_GET['$field'];
$sql = "select `$field` from doctor_info where $field like '%$val%'";
$rst = $aa->execute($sql);
while($row = mysql_fetch_array($rst)){
echo $row[0]."\n";
}
}
exit;
}
直接運(yùn)行即可實現(xiàn) 。
下面貼出來autocomplate的一些公共用法,從別的站上面粘過來的,參考方便
屬性 | 類型 | 描述 | 定義在 |
---|---|---|---|
actionPrefix | string | actionsID的前綴. | CWidget |
attribute | string | 這個widget相關(guān)的屬性. | CInputWidget |
autoFill | boolean | 選擇一個值時自動填充textinput, 替換已經(jīng)鍵入的或選擇的值. | CAutoComplete |
cacheLength | integer | 存儲在cache中的后臺查詢結(jié)果的數(shù)目. | CAutoComplete |
controller | CController | 返回這個小物件所屬的controller. | CWidget |
cssFile | mixed | 這個widget使用的CSS文件. | CAutoComplete |
data | array | 保存在客戶端提供候選選擇項的數(shù)據(jù). | CAutoComplete |
delay | integer | 當(dāng)鍵入后,autocompleter等待多少毫秒激活 . | CAutoComplete |
extraParams | array | 后端的附加參數(shù). | CAutoComplete |
formatItem | string | 為一個item提供高級標(biāo)記的javascript函數(shù). | CAutoComplete |
formatMatch | string | 用來限制autocomplete搜索匹配的數(shù)據(jù)的javascript函數(shù) . | CAutoComplete |
formatResult | string | 在結(jié)果放入input字段前,提供格式化值的javascript函數(shù) . | CAutoComplete |
highlight | boolean|string | 是否在選擇框中高亮匹配. | CAutoComplete |
htmlOptions | array | 被渲染到input tag的附加HTML選項. | CInputWidget |
id | string | 返回本小物件(widget)的ID或如果請求的話生成一個新的. | CWidget |
inputClass | string | input元素的CSS類. | CAutoComplete |
loadingClass | string | 當(dāng)數(shù)據(jù)從后端載入時使用的CSS類. | CAutoComplete |
matchCase | boolean | 是否比較時大小寫敏感. | CAutoComplete |
matchContains | boolean | 是否使用內(nèi)部比較(匹配單詞的一部分) (i. | CAutoComplete |
matchSubset | boolean | 是否autocompleter為更多的指定查詢使用緩存 . | CAutoComplete |
max | integer | select box的item數(shù)目. | CAutoComplete |
methodChain | string | 被附加到autocomplete構(gòu)造函數(shù)后的方法鏈調(diào)用. | CAutoComplete |
minChars | integer | 用戶必須鍵入的最少字符數(shù) 在autocompleter激活之前. | CAutoComplete |
model | CModel | 這個widget相關(guān)的數(shù)據(jù)模型. | CInputWidget |
multiple | boolean | 是否允許超過一個autocompleted-value輸入. | CAutoComplete |
multipleSeparator | string | 當(dāng)使用多個選項時,選項之間的分隔符. | CAutoComplete |
mustMatch | boolean | 如果設(shè)置為true,autocompleter將僅僅允許結(jié)果通過后端呈現(xiàn) . | CAutoComplete |
name | string | input 名稱. | CInputWidget |
options | array | 傳遞到autocomplete js 對象的構(gòu)造函數(shù)的附加選項. | CAutoComplete |
owner | CBaseController | 返回這個小物件的所有者/創(chuàng)造者. | CWidget |
resultsClass | string | 下拉列表的CSS類. | CAutoComplete |
scroll | boolean | 當(dāng)更多的結(jié)果超過scrollHeight設(shè)置的高度時,是否滾動. | CAutoComplete |
scrollHeight | integer | autocomplete的舉動高度(用像素)s. | CAutoComplete |
selectFirst | boolean | 如果這個設(shè)置為true,第一個autocomplete值將 被自動通過tab/回車選擇,即使沒有通過鍵盤或鼠標(biāo)精選選擇 . | CAutoComplete |
skin | mixed | 這個widget使用的皮膚名稱. | CWidget |
textArea | boolean | 是否使用一個text area顯示autocomplete. | CAutoComplete |
url | string|array | 返回候選選項的URL. | CAutoComplete |
value | string | input值 | CInputWidget |
viewPath | string | 返回這個物件包含視圖文件的目錄. | CWidget |
width | integer | 指定select box的自定義寬度. | CAutoComplete |

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

The basic syntax of PHP includes four key points: 1. The PHP tag must be ended, and the use of complete tags is recommended; 2. Echo and print are commonly used for output content, among which echo supports multiple parameters and is more efficient; 3. The annotation methods include //, # and //, to improve code readability; 4. Each statement must end with a semicolon, and spaces and line breaks do not affect execution but affect readability. Mastering these basic rules can help write clear and stable PHP code.

How to start writing your first PHP script? First, set up the local development environment, install XAMPP/MAMP/LAMP, and use a text editor to understand the server's running principle. Secondly, create a file called hello.php, enter the basic code and run the test. Third, learn to use PHP and HTML to achieve dynamic content output. Finally, pay attention to common errors such as missing semicolons, citation issues, and file extension errors, and enable error reports for debugging.

PHPisaserver-sidescriptinglanguageusedforwebdevelopment,especiallyfordynamicwebsitesandCMSplatformslikeWordPress.Itrunsontheserver,processesdata,interactswithdatabases,andsendsHTMLtobrowsers.Commonusesincludeuserauthentication,e-commerceplatforms,for

The steps to install PHP8 on Ubuntu are: 1. Update the software package list; 2. Install PHP8 and basic components; 3. Check the version to confirm that the installation is successful; 4. Install additional modules as needed. Windows users can download and decompress the ZIP package, then modify the configuration file, enable extensions, and add the path to environment variables. macOS users recommend using Homebrew to install, and perform steps such as adding tap, installing PHP8, setting the default version and verifying the version. Although the installation methods are different under different systems, the process is clear, so you can choose the right method according to the purpose.

TohandlefileoperationsinPHP,useappropriatefunctionsandmodes.1.Toreadafile,usefile_get_contents()forsmallfilesorfgets()inaloopforline-by-lineprocessing.2.Towritetoafile,usefile_put_contents()forsimplewritesorappendingwiththeFILE_APPENDflag,orfwrite()w

The key to writing Python's ifelse statements is to understand the logical structure and details. 1. The infrastructure is to execute a piece of code if conditions are established, otherwise the else part is executed, else is optional; 2. Multi-condition judgment is implemented with elif, and it is executed sequentially and stopped once it is met; 3. Nested if is used for further subdivision judgment, it is recommended not to exceed two layers; 4. A ternary expression can be used to replace simple ifelse in a simple scenario. Only by paying attention to indentation, conditional order and logical integrity can we write clear and stable judgment codes.
