---
title: "combobox--5"
author: "youyang_java"
date: "2014-06-17T11:18:18Z"
tags: []
categories: ["Web前端"]
slug: "combobox-5"
draft: false
lastmod: "2014-06-17T11:18:17Z"
id: 2080475
url: "https://youyang-java.iteye.com/blog/2080475"
---

![](http://dl2.iteye.com/upload/attachment/0098/1404/d46de71e-c6ff-30b9-832b-f0e5ca95d6db.png)  
 &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;  
&lt;html&gt;  
 &lt;head&gt;

  &lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;  
  &lt;meta http-equiv="description" content="this is my page"&gt;  
  &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;

  &lt;!-- easyui的样式 --&gt;  
  &lt;link rel="stylesheet" type="text/css"  
   href="../jslib/jquery-easyui-1.3.1/themes/default/easyui.css"&gt;  
  &lt;!-- 小图标的样式 --&gt;  
  &lt;link rel="stylesheet" type="text/css"  
   href="../jslib/jquery-easyui-1.3.1/themes/icon.css"&gt;

  &lt;script type="text/javascript"  
   src="../jslib/jquery-easyui-1.3.1/jquery-1.8.0.min.js"&gt;&lt;/script&gt;  
  &lt;script type="text/javascript"  
   src="../jslib/jquery-easyui-1.3.1/jquery.easyui.min.js"&gt;&lt;/script&gt;  
  &lt;script type="text/javascript"  
   src="../jslib/jquery-easyui-1.3.1/locale/easyui-lang-zh\_CN.js"&gt;&lt;/script&gt;

  &lt;script type="text/javascript"&gt;  
   var loginComboboxName;  
   var d = [ {  
    "id" : 1,  
    "text" : "text1"  
   }, {  
    "id" : 2,  
    "text" : "text2"  
   }, {  
    "id" : 3,  
    "text" : "text3",  
    "selected" : true  
   }, {  
    "id" : 4,  
    "text" : "Text4"  
   }, {  
    "id" : 5,  
    "text" : "text5"  
   } ];  
   $(function() {  
    loginComboboxName = $('#loginComboboxName').combobox({  
     data : d,  
     textField : 'text',  
     valueField : 'id',  
     filter : function(q, row) {  
      var opts = $(this).combobox('options');  
      //return row\[opts.textField].indexOf(q) == 0;  
      return row\[opts.textField].toUpperCase().indexOf(q.toUpperCase()) == 0;  
     },  
     formatter : function(row) {  
      var opts = $(this).combobox('options');  
      return row\[opts.textField] + "###";  
     },  
     onBeforeLoad : function(param) {  
      console.info(param);  
     },  
     multiple : true  
    });  
   });  
    
   function loadData() {  
    loginComboboxName.combobox('loadData', [ {  
     "id" : 1,  
     "text" : "aaaaaa"  
    }, {  
     "id" : 2,  
     "text" : "bbbbb"  
    }, {  
     "id" : 3,  
     "text" : "ccccc",  
     "selected" : true  
    }, {  
     "id" : 4,  
     "text" : "ddddd"  
    }, {  
     "id" : 5,  
     "text" : "eeeee"  
    } ]);  
   }  
  &lt;/script&gt;  
 &lt;/head&gt;  
 &lt;body&gt;  
  &lt;select id="loginComboboxName" name="name"  
   style="display: none; width: 157px;"&gt;&lt;/select&gt;  
  &lt;input type="button"  
   onclick="console.info(loginComboboxName.combobox('getData'))"  
   value="getData" /&gt;

  &lt;input type="button" onclick="loadData()" value="loadData" /&gt;  
  &lt;input type="button" onclick="loginComboboxName.combobox('clear')"  
   value="clear" /&gt;  
 &lt;/body&gt;  
&lt;/html&gt;