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

O

Oskar

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>
 
R

Richard Cornford

Oskar said:
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?
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top