1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 |
<HTML> |
<HTML> |
3 |
<HEAD> |
<HEAD> |
4 |
<TITLE> New Document </TITLE> |
<TITLE>Combobox example</TITLE> |
5 |
|
|
6 |
<style type="text/css"> |
<style type="text/css"> |
7 |
#textfilterholder { |
#textfilterholder { |
38 |
|
|
39 |
|
|
40 |
<script type="text/javascript" src="bfilter.js"></script> |
<script type="text/javascript" src="bfilter.js"></script> |
41 |
|
<script type="text/javascript" src="combo-test.js"></script> |
42 |
<script type="text/javascript"> |
<script type="text/javascript"> |
43 |
|
|
44 |
var headlines = new Object(); |
var combo_active = 1; |
45 |
headlines['ad'] = [ |
|
46 |
['thes/232.html','adacta'] |
function combo_onKeyDown(event) { |
47 |
, ['thes/232.html','added'] |
//debug("event: "+event.keyCode); |
48 |
, ['thes/232.html','addenda'] |
if (event.keyCode == 13) { |
49 |
, ['thes/232.html','adlib'] |
var el = document.myfilter.element_id('textfilter'); |
50 |
]; |
if (el) el.focus(); |
51 |
|
|
52 |
|
el = document.myfilter.element_id('results'); |
53 |
|
if (el) el.innerHTML = ''; |
54 |
|
|
55 |
|
combo_active = 0; |
56 |
|
} |
57 |
|
|
58 |
|
} |
59 |
|
|
|
headlines.min_len = 2; |
|
|
headlines.length = 4; |
|
60 |
|
|
61 |
function myfilter() { |
function myfilter() { |
62 |
|
|
63 |
document.getElementById('textfilter').focus(); |
document.getElementById('textfilter').focus(); |
64 |
document.getElementById('textfilter').caretPos=1; |
document.getElementById('textfilter').caretPos=1; |
65 |
// document.getElementById('textfilter').select(); |
// document.getElementById('textfilter').select(); |
66 |
document.myfilter = new BFilter(headlines); |
document.myfilter = new BFilter(headlines); |
67 |
|
|
68 |
document.myfilter.html_pre = '<option value="'; |
document.myfilter.result = function (arr) { |
69 |
document.myfilter.html_mid = '">'; |
return '<option value="'+arr[1]+'">'+ |
70 |
document.myfilter.html_post = '</option>'; |
arr[0] + |
71 |
document.myfilter.html_full_pre = '<select id="sel" size="5" onkeydown="if (event.keyCode==13) document.getElementById(\'textfilter\').focus();" onchange="document.getElementById(\'textfilter\').value = this.options[this.selectedIndex].text;">'; |
'</option>'; |
72 |
document.myfilter.html_full_post = '</select>'; |
} |
73 |
|
|
74 |
|
// this function is called when updating innerHTML with results |
75 |
|
document.myfilter.display = function (html) { |
76 |
|
return '<select id="sel" size="5" onKeyDown="combo_onKeyDown(event);" onChange="document.getElementById(\'textfilter\').value = this.options[this.selectedIndex].text;">'+html+'</select>'; |
77 |
|
} |
78 |
|
} |
79 |
|
|
80 |
|
function combo_filter(document,value) { |
81 |
|
|
82 |
|
if (! combo_active) { |
83 |
|
return null; |
84 |
|
} |
85 |
|
|
86 |
|
return document.myfilter.filter(document, value, headlines); |
87 |
} |
} |
88 |
|
|
89 |
function keypress(e) { |
function keypress(e) { |
91 |
if ((d == 37) || (d == 38) || (d == 39) || (d == 40)) { |
if ((d == 37) || (d == 38) || (d == 39) || (d == 40)) { |
92 |
if (document.getElementById('sel')) document.getElementById('sel').focus(); |
if (document.getElementById('sel')) document.getElementById('sel').focus(); |
93 |
} |
} |
94 |
|
|
95 |
|
if (d != 13) combo_active = 1; |
96 |
} |
} |
97 |
|
|
98 |
</script> |
</script> |
105 |
<BODY onload="myfilter();"> |
<BODY onload="myfilter();"> |
106 |
|
|
107 |
<div id="filterholder"> |
<div id="filterholder"> |
108 |
<div id="textfilterholder"><input autocomplete="off" id="textfilter" name="textfilter" type="text" onkeyup="document.myfilter.filter(document, this.value, headlines);" onKeyDown="keypress(event);" value=""></div> |
<div id="textfilterholder"> |
109 |
|
<input autocomplete="off" id="textfilter" name="textfilter" type="text" |
110 |
|
onKeyDown="keypress(event);" |
111 |
|
onKeyUp="combo_filter(document, this.value);" |
112 |
|
value=""></div> |
113 |
|
|
114 |
<div id="results"> |
<div id="results"> |
115 |
</div> |
</div> |
116 |
|
|
|
<div id="status"> |
|
117 |
</div> |
</div> |
118 |
|
|
119 |
|
<div id="status"> |
120 |
</div> |
</div> |
121 |
|
|
122 |
|
<div style="color: #a0a0a0"> |
123 |
Text |
If this combobox isn't working for you, try running <tt>make combo</tt> to create |
124 |
|
example data from first 10000 words in <tt>/usr/share/dict/words</tt>. |
125 |
|
</div> |
126 |
|
|
127 |
</BODY> |
</BODY> |
128 |
</HTML> |
</HTML> |