Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 17th, 2006, 06:05 AM
Oskar
Guest
 
Posts: n/a
Default filter on items in select (ie6 bug?/hidden feature?)

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>


  #2  
Old August 17th, 2006, 07:55 AM
Richard Cornford
Guest
 
Posts: n/a
Default 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.


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.