View Full Version : search inside a option
I saw a script where when you type someword in textbox and the option field also highlighting the word if was exist in the option field.
for example:
http://i56.tinypic.com/w88itc.jpg
do anyone know any script, thanks!
vwphillips
09-22-2010, 04:13 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
function Select(ip,sel){
sel=document.getElementById(sel);
var opts=sel.options;
var txt=ip.value.split(' ');
for (var s,z0=0;z0<opts.length;z0++){
opts[z0].selected=false;
s=opts[z0].text.split(' ');
for (var z0a=0;z0a<txt.length;z0a++){
for (var z0b=0;z0b<s.length;z0b++){
if (txt[z0a]&&s[z0b]&&txt[z0a].toUpperCase()==s[z0b].toUpperCase()){
opts[z0].selected=true;
}
}
}
}
}
/*]]>*/
</script>
</head>
<body>
<input name="fred" onkeyup="Select(this,'tst');"/>
<select name="tst" size="3" multiple="multiple">
<option>Tom</option>
<option>****</option>
<option>Harry Tom</option>
</select>
</body>
</html>
thank you so much, but doesn't seems to highlight anything.
sorry to be rude at the 1st time.
vwphillips
09-23-2010, 08:46 AM
oops
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
function Select(ip,sel){
sel=document.getElementById(sel);
var opts=sel.options;
var txt=ip.value.split(' ');
for (var s,z0=0;z0<opts.length;z0++){
opts[z0].selected=false;
s=opts[z0].text.split(' ');
for (var z0a=0;z0a<txt.length;z0a++){
for (var z0b=0;z0b<s.length;z0b++){
if (txt[z0a]&&s[z0b]&&txt[z0a].toUpperCase()==s[z0b].toUpperCase()){
opts[z0].selected=true;
}
}
}
}
}
/*]]>*/
</script>
</head>
<body>
<input name="fred" onkeyup="Select(this,'tst');"/>
<select id="tst" size="3" multiple="multiple">
<option>Tom</option>
<option>****</option>
<option>Harry Tom</option>
</select>
</body>
</html>
thanks you so much... works 100%.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.