大下拉框过滤 Filtering Large Select Lists(GPL开源协议)

本文介绍了一种利用JavaScript实现的实时过滤技术,用于优化大型选择列表的用户体验。通过提供快速筛选功能,用户可以轻松查找所需选项,显著提高网站或应用的交互效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[url=http://www.barelyfitz.com/projects/filterlist/index.php/2]Filtering Large Select Lists[/url]


<html><head>
<meta http-equiv="content-type" content="text/html; charset=GB2312">
<title>Filterlist Example</title>

<!-- Load the javascript code -->
<script type="text/javascript" src="example_files/filterlist.js"></script>

</head>
<body>
<h1>Filterlist Example</h1>

<form name="myform" action="">

<select name="myselect" size="5">
<option>Keanu Reeves
</option><option>Laurence Fishburne
</option><option>汉字
</option><option>汉语
</option><option>Nona Gaye
</option><option>Lachy Hulme
</option><option>Nathaniel Lees
</option><option>Harry J. Lennix
</option><option>Matt McColm
</option><option>Carrie-Anne Moss
</option><option>Collin Chou
</option><option>Genevieve O'Reilly
</option><option>Harold Perrineau Jr.
</option><option>Jada Pinkett Smith
</option><option>Adrian Rayment
</option><option>Neil Rayment
</option><option>Bruce Spence
</option><option>Hugo Weaving
</option><option>Lambert Wilson
</option><option>Anthony Wong
</option></select>

<script type="text/javascript">
<!--
var myfilter = new filterlist(document.myform.myselect);
//-->
</script>

<p>
Filter:
<a href="javascript:myfilter.reset()" title="Clear the filter">Clear</a>
<a href="javascript:myfilter.set('^A')" title="Show items starting with A">A</a>
<a href="javascript:myfilter.set('^B')" title="Show items starting with B">B</a>
<a href="javascript:myfilter.set('^C')" title="Show items starting with C">C</a>
<a href="javascript:myfilter.set('^D')" title="Show items starting with D">D</a>
<a href="javascript:myfilter.set('^E')" title="Show items starting with E">E</a>
<a href="javascript:myfilter.set('^F')" title="Show items starting with F">F</a>
<a href="javascript:myfilter.set('^G')" title="Show items starting with G">G</a>
<a href="javascript:myfilter.set('^H')" title="Show items starting with H">H</a>
<a href="javascript:myfilter.set('^I')" title="Show items starting with I">I</a>
<a href="javascript:myfilter.set('^J')" title="Show items starting with J">J</a>
<a href="javascript:myfilter.set('^K')" title="Show items starting with K">K</a>
<a href="javascript:myfilter.set('^L')" title="Show items starting with L">L</a>
<a href="javascript:myfilter.set('^M')" title="Show items starting with M">M</a>
<a href="javascript:myfilter.set('^N')" title="Show items starting with N">N</a>
<a href="javascript:myfilter.set('^O')" title="Show items starting with O">O</a>
<a href="javascript:myfilter.set('^P')" title="Show items starting with P">P</a>
<a href="javascript:myfilter.set('^Q')" title="Show items starting with Q">Q</a>
<a href="javascript:myfilter.set('^R')" title="Show items starting with R">R</a>
<a href="javascript:myfilter.set('^S')" title="Show items starting with S">S</a>
<a href="javascript:myfilter.set('^T')" title="Show items starting with T">T</a>
<a href="javascript:myfilter.set('^U')" title="Show items starting with U">U</a>
<a href="javascript:myfilter.set('^V')" title="Show items starting with V">V</a>
<a href="javascript:myfilter.set('^W')" title="Show items starting with W">W</a>
<a href="javascript:myfilter.set('^X')" title="Show items starting with X">X</a>
<a href="javascript:myfilter.set('^Y')" title="Show items starting with Y">Y</a>
<a href="javascript:myfilter.set('^Z')" title="Show items starting with Z">Z</a>

</p><p>

<!--
Note: if you have a very large select list,
you should deactivate the real-time filtering
on the INPUT field below - remove the onKeyUp attribute.
-->
Filter by regular expression:<br>
<input name="regexp" onkeyup="myfilter.set(this.value)">
<input onclick="myfilter.set(this.form.regexp.value)" value="Filter" type="button">
<input onclick="myfilter.reset();this.form.regexp.value=''" value="Clear" type="button">

<br>

<input name="toLowerCase" onclick="myfilter.set_ignore_case(!this.checked)" type="checkbox">
Case-sensitive

</p></form>


</body></html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值