Html
Copy codeThe Code is as follows:
<P> <span style = "font-size: 18px;"> the input box automatically matches characters ~ </Span> </p> <span style = "font-size: 18px;"> however, a problem occurs ~ All matched characters must be written in advance ~ If it is a large website ~ Use Database records </span> </p> <span style = "font-size: 18px; "> View Code </span> </p>
Html
Copy codeThe Code is as follows:
<Style>
Ul, li {margin: 0; padding: 0; width: 100% ;}
</Style>
<Script language = "javascript" type = "text/javascript">
Function checkword ()
{
Var wordvalue = document. getElementById ("word"). value. toLowerCase ();
Var alltxt = "all | big | cut | car \ | daph8 | eeg | egg | eat | fuck you | fix | good | hand | hidden | ill | jack | jad | kevin | long | man | number | oio | part | pp | quit | QQ | rest | reg | set | submit | time | tag | uzo | view | windows | want | xy | xun | young | yuyu | z | David | Haha | "; // here is the character you want to match. Unfortunately, it can only be used for small forums.
Var alltxtalltxtpp = alltxt. toLowerCase ();
Var alltxtalltxt_xiang = alltxt. split ("| ");
Var alltxt_xiang1 = alltxtpp. split ("| ");
Var inhtml = "<ul>"
Var isyou = 0;
For (I = 0; I <alltxt_xiang1.length; I ++)
{
If (alltxt_xiang1 [I]. substr (0, wordvalue. length) = wordvalue)
{
Inhtmlinhtml = inhtml + "<li onclick = \" document. getElementById ('word '). value = this. innerHTML; document. getElementById ('showmenu '). style. display = 'none'; \ "onmouseover = \" this. style. backgroundColor = '#666666' \ "onmouseout = \" this. style. backgroundColor = ''\"> "+ alltxt_xiang [I] +" </li> ";
Isyou = 1;
}
}
Inhtmlinhtml = inhtml + "</ul> ";
If (isyou = 1)
{
Document. getElementById ("showmenu"). innerHTML = inhtml;
Document. getElementById ("showmenu"). style. display = "";
}
Else
{
Document. getElementById ("showmenu"). innerHTML = "";
Document. getElementById ("showmenu"). style. display = "none ";
}
If (wordvalue = "")
{
Document. getElementById ("showmenu"). innerHTML = "";
Document. getElementById ("showmenu"). style. display = "none ";
}
}
</Script>
<Input type = "text" name = "word" size = "20" id = "word" onkeyup = "checkword ()" style = "border: 1px solid #666666; width: 200px; height: 25px; ">
<Div style = "position: absolute; width: 200px; height: 100px; z-index: 1; left: 10px; top: 40px; border: 1px solid #666666; display: none; "id =" showmenu "> </div>