Connecting Tech Pros Worldwide Help | Site Map

filter on items in select (ie6 bug?/hidden feature?)

Oskar
Guest
 
Posts: n/a
#1: Aug 17 '06
Hi.
I'm have a page thas shows a list of items and a text input box. The
text input box works as a filter and the javascript hides the elements
that do not contain the String from the input box.
In firefox this works perfect.. in IE6 I can't get it working, anybody
an idea?

source:

<html>
<body>
<script>
function filter(obj){
var veld = document.getElementById('list');
var str=obj.value;
for (var loop= (veld.options.length-1) ; loop >= 0; loop--){
if (veld.options[loop].text.search(str) == -1){
veld.options[loop].style.display = 'none';
}
else{
veld.options[loop].style.display = '';
}
}
}
</script>
<input type="text" onkeyup="filter(this)"/>
<select multiple="multiple" class="swapfield" size="10" name="list"
id="list">
<option value="1">Wout Netjes</option>
<option value="2">Trudi Netjes</option>
<option value="3">jeroen Bos</option>
<option value="4">Marietje Bos</option>
</select>
</body>
</html>

Richard Cornford
Guest
 
Posts: n/a
#2: Aug 17 '06

re: filter on items in select (ie6 bug?/hidden feature?)


Oskar wrote:
Quote:
I'm have a page thas shows a list of items ... hides the
elements that ... .
In firefox this works perfect.. in IE6 I can't get it
working, anybody an idea?
>
<snip>
Quote:
veld.options[loop].style.display = 'none';
<snip>

IE does not support CSS styles applied to individual OPTION elements. IF
you want them not to be shown to the user you must remove them form the
SELECT element's options collection (and re-instate them to return them
to visibility).

Richard.


Closed Thread


Similar JavaScript / Ajax / DHTML bytes