suggest.jsã¯googleサジェストã®ãããªå ¥åè£å®ãè£å©ãã¦ãããjavascriptã©ã¤ãã©ãªã§ããã
ããæ°æ¥ãsuggest.jsãã¤ãã£ã¦æºå¸¯ã¡ã¼ã«ãã©ã¼ã ã®ãï¼ ã以éã®è£å®ãä½ããªãããªã¨æãæ ¼éãã¦ããã
prototype.jsã®Form.Element.Observerã¤ãã£ã¦ããã©ã¼ã ã«å
¥åãããå¤ãç£è¦ãã¦ããã¦ããï¼ ããå
¥åããããé
åã代å
¥ãããããªãã
åç¥(CSSè¨å®ãprototype.jsãsuggest.jsè¨å®ã¾ã§ã¯å ¬å¼ãµã¤ãä¾ã¨åã) --------------------------------------------------------------------- <script type="text/javascript" language="javascript"> <!-- // è£å®åè£ã®é åä½æ var list = []; var flag = 0; var suggest; // wondowã®onloadã¤ãã³ãã§Suggestãçæ Event.observe(window, 'load', function(){ suggest =new IncSearch.SuggestTag("text", "suggest", list, {dispAllKey: true, prefix: true}); }, false); //textãã©ã¼ã ãç£è¦ window.onload = function(){ new Form.Element.Observer($('text'),1, function(){ if($("text").value.indexOf("@",0) != -1 && flag == 0) { list.clear; ããããããããlist = [ 'docomo.ne.jp', 'ezweb.ne.jp', ããããããããããããã'q.vodafone.ne.jp', 'softbank.ne.jp']; ããããããããflag = 1; ãããããã} } ); } //--> </script> </head> <body> <input id="text" type="text" name="pattern" value="" autocomplete="off" size="40" style="display: block"/> <!-- è£å®åè£ã表示ããã¨ãªã¢ --> <div id="suggest"></div> </body> </html>
åãããã¨ãããåãããããªãã®ãï¼
suggest.jsã®candidateListããããå¼ãã°åããããªãã ããã
ãã¼ã¤ããã¾ããã
2006/11/02 12:32:54*追è¨
<script type="text/javascript" language="javascript"> <!-- // è£å®åè£ã®é åä½æ var list = [ [], ['docomo.ne.jp', 'ezweb.ne.jp', 'q.vodafone.ne.jp', 'softbank.ne.jp'] ]; var flag = 0; // wondowã®onloadã¤ãã³ãã§Suggestãçæ Event.observe(window, 'load', function(){ var suggest =new IncSearch.SuggestTag("text", "suggest", list[flag],{delim: "@"}); new Form.Element.Observer($('text'),1, function(){ if($("text").value.indexOf("@",0) != -1 && flag == 0) { alert('ok'); flag = 1; suggest.candidateList = list[flag]; } } ); }, false); //--> </script>
ããã§ä¸å¿åããã¨ã«ã¯åããã ãã©ï½¥ï½¥ï½¥ãä¸çªå¾ãã«ï¼ ãã¤ãã¦ãã¾ãã
ãªãããã£ã¨ã¹ãã¼ããªæ¹æ³ããããããªãã ããã