可输入的select 的下拉框

//根据导师查询学生下拉框信息(combogrid)
function loadNetTeacher(){
	$('#cg').combogrid({
		 panelWidth: 480,
		 panelHeight:310,
		 idField:'id',   
		 textField:'user',
		 url:'netTeacher.do?action=listAllNT', 
		 fitColumns: true,
	     striped: true,
	     editable: true,
	     pagination: true,           //是否分页
	     rownumbers: true,           //序号
	     collapsible: false,         //是否可折叠的
	     fit: true,
	     method: 'post',
		 columns : [[{
				field : 'id',
				title : '导师编号',
				width : 150,
				align : 'center',
				rowspan : 2,
				formatter : function(value, rec) {
					return value;
				}
			},{
				field : 'user',
				title : '导师用户名',
				width : 296,
				align : 'center',
				rowspan : 2,
				showRefresh: false,
				formatter : function(value, rec) {
					return rec.user.username;
				}
			}
		 ] ]
	});
	//取得分页组件对象
	    var pager = $('#cg').combogrid('grid').datagrid('getPager');
	    if (pager) {
	       $(pager).pagination({
	    	   total:100,
	           pageList: [5,10],   
	    	   showRefresh: false,
	    	   beforePageText : '第',
	   		   afterPageText : '共{pages}页',
	   		   displayMsg: ' 共100 条',
	    	   onSelectPage : function(pageNumber, pageSize) {
	    		   
	    	   }
	        });
	    }
}
 <html> <head> <title>可输入的select下拉框</title> </head> <script> </script> <body > <select style='width:150px;z-index:-1' id="aa" name="selectHelpCode" onkeydown="if(event.keyCode == 8){this.options[0].text = '';}" onkeypress="writeSelect(this)"> <option value="0"></option> <option value="11">11</option> <option value="22">22</option> <option value="33">33</option> </select> <input type="button" value="点我" onclick="ttt();"/> <script> function writeSelect(obj){ obj.options[0].selected = "select"; obj.options[0].text = obj.options[0].text + String.fromCharCode(event.keyCode); event.returnValue=false; return obj.options[0].text; } function ttt(){ var ss = document.getElementById("aa").value; var jg = ""; if(ss == ""){ var aas = writeSelect(document.getElementById("aa")); jg = aas; }else{ jg = document.getElementById("aa").value; } alert(jg); } </script> </body> </html>

 

你可能感兴趣的:(select)