惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
H
Hacker News: Front Page
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cisco Blogs
P
Palo Alto Networks Blog
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
S
Schneier on Security
The Hacker News
The Hacker News
Cyberwarzone
Cyberwarzone
T
Tenable Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tailwind CSS Blog
S
Secure Thoughts
N
Netflix TechBlog - Medium
T
The Exploit Database - CXSecurity.com
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Help Net Security
Help Net Security
K
Kaspersky official blog
Google Online Security Blog
Google Online Security Blog
L
LangChain Blog
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
Hacker News: Ask HN
Hacker News: Ask HN
www.infosecurity-magazine.com
www.infosecurity-magazine.com
有赞技术团队
有赞技术团队
P
Privacy International News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Announcements
Recent Announcements
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
Recorded Future
Recorded Future
The Last Watchdog
The Last Watchdog
G
Google Developers Blog
T
Threatpost
小众软件
小众软件
S
Securelist
Recent Commits to openclaw:main
Recent Commits to openclaw:main
O
OpenAI News

博客园 - sdxd.bgl

将SQL Server中的数据显示到SharePoint中 拓展训练总结 在PowerShell中,如何获取SharePoint的默认数据库服务器 在SharePoint页面中如何显示来自其他网站的List 恢复导出XSLT List View WebPart 实战部署FAST Search Server 2010 for SharePoint Sharepoint开发中代码运行权限级别 在InfoPath中如何获取当前用户的信息(Profile) 晒晒我的家乡 关于模式的思考 小心委托 利用System.Linq.Expressions实现四则运算计算器(三) 利用System.Linq.Expressions实现四则运算计算器(二) 利用System.Linq.Expressions实现四则运算计算器(一) 初识System.Linq.Expressions 请拆招:将两个已排序集合分解成两个独立部分的集合和一个共有部分的集合? 如何实现Windows服务 我的生活 电脑是个神奇的东西!
用javascript实现下拉列表的自动筛选功能 - sdxd.bgl - 博客园
sdxd.bgl · 2007-01-16 · via 博客园 - sdxd.bgl

下拉列表大家都用的多了,如果下拉列表里面有太多项,用户在查找其中的一项就比较困难。这种时候大家都会想到排序,但有时候关键字不总是排在第一位,排序后还是有些难找。对下拉列表项目进行简单筛选就变得特别有效。

function SelectFilter(sel)
{
    
var txt = window.prompt("请输入过滤条件:""");
    
if(document.filter == undefined)
    {
        document.filter 
= new Array();
    }
    
if(document.filter[sel.id] == undefined)
    {
        document.filter[sel.id] 
= new Array();
        
for(var i = 0; i < sel.options.length; i++)
        {
            document.filter[sel.id][i] 
= sel.options[i];
        }
    }
    
else
    {
        
for(var i = sel.options.length - 1; i >= 0; i--)
        {
            sel.options.remove(i);
        }
        
for(var i = 0; i < document.filter[sel.id].length; i++)
        {
            sel.options.add(document.filter[sel.id][i]);
        }
    }
    
if(txt == undefined || txt == "")
    {
        
return;
    }
    
for(var i = sel.options.length - 1; i >= 0; i--)
    {
        
if(sel.options[i].text.indexOf(txt) < 0)
        {
            sel.options.remove(i);
        }
    }
    
if(sel.options.length > 0)
    {
        sel.options[
0].selected = true;
    }
}

在使用的时候,向如下调用:

1 <input type="button" value="" onclick="javascript:SelectFilter(<%= ddlInterval.ClientID %>);">

看看效果,应用之前:

进行筛选,输入2422:

筛选出来的结果:


之前发的脚本还有些小问题,如果用户点“取消”按钮,会将下拉项全部清空,也不会默认选择第一项。这些都已经修正。