可搜索输入的下拉框(下拉菜单) - 单身小熊's Blog

可搜索输入的下拉框(下拉菜单)

单身小熊 posted @ 2010年6月30日 16:30 in ASP with tags 表单特效 , 2882 阅读


   提醒 复制代码后可点此测试代码运行效果

 可搜索输入的下拉框(下拉菜单)

效果:

<HTML> 
	<HEAD> 
		<TITLE>可搜索输入的下拉框(下拉菜单)</TITLE> 
	</HEAD> 
	<Script Language="JavaScript"> 
		<!--
		   var whichText;
		   function selectStation(obj) {
		   	   var objSelStation = obj;
		       if (obj.selectedIndex != -1) {
		           var stationName = obj.options[obj.selectedIndex].text;
		           whichText.value = stationName;
		       }
		       var stobj= document.getElementsByName('hospitalCode')[0];
		       //鼠标单击某一选项选定后关闭下拉框
		       showDivStation(this, false,'hospitalCode')
		    }
		
			//响应text的事件
		   	var pageD =0, pageU;
		   	function similarFind(txtObj,seledName) {
		        var curStationName = txtObj.value;
		        var objSelStation = document.getElementsByName(seledName)[0];
		        var stationLength = objSelStation.options.length;
		        var flag = true;
		   		pageU = pageD;
		        //从起始的文字匹配 用text中的数据跟下拉框中的数据
		        for (var i=0; i<stationLength; i++) {
		            var stationName = objSelStation.options[i].text;
		            var re = new RegExp("^" + curStationName);
		       		if (stationName.match(re)) {
		                if (i<stationLength - 10) {
		                    objSelStation.selectedIndex = i + 10;
		                }
		                objSelStation.selectedIndex = i;
		       			pageD = i;
		       			pageU = i;
		       			flag = false;
		                break;
		            }
		        }
		        ////从文字中匹配 用text中的数据跟下拉框中的数据
		        if(flag) {
		        	for (var i=0; i<stationLength; i++) {
			            var stationName = objSelStation.options[i].text;
			            var re2 = new RegExp("^.*" + curStationName+'.*$');
			       		if (stationName.match(re2)) {
			                if (i<stationLength - 10) {
			                    objSelStation.selectedIndex = i + 10;
			                }
			                objSelStation.selectedIndex = i;
			       			pageD = i;
			       			pageU = i;
			                break;
			            }
		        	}
		        }
				//响应下移键
			   	if(event.keyCode==40) {
			     	pageD++;
			     	if(pageD==objSelStation.options.length) pageD=0;
			     	txtObj.value=objSelStation.options[pageD].text ;
			     	objSelStation.selectedIndex = pageD;
			   	}
				//响应上移键
			   	if(event.keyCode==38) {
			     	--pageU;
			     	if(pageU<0) pageU=objSelStation.options.length-1;
			     	txtObj.value = objSelStation.options[pageU].text;
			     	objSelStation.selectedIndex = pageU;
			    }
			}
			//下拉框显示位置
		    function showDivStation(obj, b,selName) {
		        var divStation = document.getElementsByName(selName)[0]
		        if (b) {
		           whichText = obj;
		           divStation.style.display="block";
		           similarFind(obj,selName);
		        } else {
		           divStation.style.display="none";
		        }
		    }
		    
		    function removeNull(node) {
		    	if(node.value=='--未选择--') 
		    	node.value = '';
		    }
		//--> 
	</Script> 
	<BODY bgcolor="#FFFFFF" topmargin="0" leftmargin="0"> 
		<form name="caseLhBaseForm"> 
			<table> 
				<tr> 
					<td valign="top">医院</TD> 
					<td> 
						<input type="text" name="hospitalCodeName" 

							style="width: 330px"

							onfocus="showDivStation(this, true,'hospitalCode')" 

							onclick="removeNull(this)"

							onkeyup="similarFind(this,'hospitalCode')" 

							value="--未选择--"> 
						<select size="6" name="hospitalCode"

							style="display: none; width: 330px;"

							onclick="selectStation(this)"> 
							<option value="">--未选择--</option> 
							<option value="340403007">北京上地医院</option> 
							<option value="340402006">北京回龙观医院</option> 
							<option value="340401005">北京中关村医院</option> 
							<option value="340401005">上地第二医院</option> 
							<option value="340403007">回龙观第二医院</option> 
							<option value="340402006">朝阳医院</option> 
							<option value="340401005">海淀医院</option> 
							<option value="340401005">东城区医院</option> 
						</select> 
					</td> 
				</tr> 
			</table> 
		</form> 
	</BODY> 
</HTML>
  • 无匹配
NCERT Sanskrit Quest 说:
2022年9月27日 13:02

The 10th class studying in all Central & State Boards of the country can download NCERT STD-10 Sanskrit Sample Paper 2023 with answers that’s supports for all formats of exams such as SA1, SA2, FA1, FA2, FA3, FA4 and Assignments held under Term-1 & Term-2 of the course. NCERT Sanskrit Question Paper Class 10 By downloading and practice these NCERT 10th Class Sanskrit model papers 2023 every student may get an analysis on the question paper pattern, important questions and the way of asking.

boardmodelpaper.com 说:
2024年1月21日 18:51

Board Model Papers 2024 Download with Suggestions for 10th Class Textbooks 2024 Pdf Download and SSLC New Syllabus Sample Question Paper 2024 and different types of model papers boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course Languages & Subjects Important Question for the above link.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee