html
复制代码 代码如下:
<p><span style="font
size:
px; ">输入框自动匹配字符~</span></p><p><span style="font
size:
px; ">但是遇到一个问题~所有匹配的字符要事先写好~大概如果是大型网站的话~应该是利用数据库的记录吧</span>< /p><p><span style="font
size:
px; ">看代码</span></p>
html
复制代码 代码如下:
<style>
ulli{margin: ; padding: ;width:%;}
</style>
<script language="javascript" type="text/javascript">
function checkword()
{
var wordvalue=documentgetElementById("word")valuetoLowerCase();
var alltxt="all|big|cut|car|daph|eeg|egg|eat|fuck|fuck you|fix|good|hand|hidden|ill|jack|jad|kevin|long|man|number|oio|part|pp|quit|QQ|rest|reg|set|submit|time|tag|uuzo|view|windows|want|xy|xun|young|yuyu|z|David|David| 哈哈|";//这里就是你所想要匹配的字符可惜只能用于小型的论坛
var alltxtalltxtpp=alltxttoLowerCase();
var alltxtalltxt_xiang=alltxtsplit("|");
var alltxt_xiang=alltxtppsplit("|");
var inhtml="<ul>"
var isyou=;
for (i=;i<alltxt_xianglength;i++)
{
if (alltxt_xiang[i]substr(wordvaluelength)==wordvalue)
{
inhtmlinhtml=inhtml+"<li onclick="documentgetElementById(word)value=thisinnerHTML;documentgetElementById(showmenu)styledisplay=none;" onmouseover="thisstylebackgroundColor=#" onmouseout="thisstylebackgroundColor=">"+alltxt_xiang[i]+"</li>";
isyou=;
}
}
inhtmlinhtml=inhtml+"</ul>";
if (isyou==)
{
documentgetElementById("showmenu")innerHTML=inhtml;
documentgetElementById("showmenu")styledisplay="";
}
else
{
documentgetElementById("showmenu")innerHTML="";
documentgetElementById("showmenu")styledisplay="none";
}
if (wordvalue=="")
{
documentgetElementById("showmenu")innerHTML="";
documentgetElementById("showmenu")styledisplay="none";
}
}
</script>
<input type="text" name="word" size="" id="word" onkeyup="checkword()" style="border:px solid #;width:px;height:px;">
<div style="position: absolute; width: px; height: px; zindex: ; left: px; top: px;border:px solid #;display:none;" id="showmenu"></div>