html左侧为筛选栏右侧刷新,如何自动筛选HTML选择列表?

我会设置一个缓存来保存

options

在我的内心

select

. 而不是过滤

选项

选择

,我会清除

选择

,并用匹配的

选项

.

大量伪代码:

onLoad:

set cache

onKeyPress:

clear select-element

find option-elements in cache

put found option-elements into select-element

这是我写的一个小POC,过滤

selects

从另一个中选择的内容

选择

--实际上,将一组选择链接在一起。

也许它能给你一些想法:

function selectFilter(_maps)

{

var map = {};

var i = _maps.length + 1; while (i -= 1)

{

map = _maps[i - 1];

(function (_selectOne, _selectTwo, _property)

{

var select = document.getElementById(_selectTwo);

var options = select.options;

var option = {};

var cache = [];

var output = [];

var i = options.length + 1; while (i -= 1)

{

option = options[i - 1];

cache.push({

text: option.text,

value: option.value,

property: option.getAttribute(_property)

});

}

document.getElementById(_selectOne).onchange = function ()

{

var selectedProperty = this

.options[this.selectedIndex]

.getAttribute(_property);

var cacheEntry = {};

var cacheEntryProperty = undefined;

output = [];

var i = cache.length + 1; while (i -= 1)

{

cacheEntry = cache[i - 1];

cacheEntryProperty = cacheEntry.property;

if (cacheEntryProperty === selectedProperty)

{

output.push("

_property + "=" + cacheEntryProperty + ">" +

cacheEntry.text + "

");

}

}

select.innerHTML = output.join();

};

}(map.selectOne, map.selectTwo, map.property));

}

}

$(function ()

{

selectFilter([

{selectOne: "select1", selectTwo: "select2", property: "entityid"},

{selectOne: "select2", selectTwo: "select3", property: "value"}

]);

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值