📄 104.html
字号:
document.write(myyear+"-"+mymonth+"-"+myday);</script>,欢迎访问Ok3w新闻发布系统!</td>
<td align="right" class="green12gray"><a href="guest.asp">请您留言</a> | <a href="http://www.glzy8.com/ok3w/article/147.html" target="_blank">免费下载</a> | <a href="#" class="green12gray" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(document.URL);">设为首页</a> | <a href="#" class="green12gray" onclick="window.external.AddFavorite(document.URL,document.title);">加入收藏</a></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:2px;">
<tr>
<td align="left"><iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="468" height="60" src="http://spcode.baidu.com/spcode/spstyle/style2220.jsp?tn=zhengbi_sp&ctn=0&styleid=2220"></iframe></td>
<td align="right"><iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="468" height="60" src="http://spcode.baidu.com/spcode/spstyle/style1634.jsp?tn=zhengbi_sp&ctn=0&styleid=1634"></iframe></td>
</tr>
<tr>
<td colspan="2" align="left" height="5"></td>
</tr>
<tr>
<td align="left"><iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="468" height="60" src="http://spcode.baidu.com/spcode/spstyle/style2615.jsp?tn=zhengbi_sp&ctn=0&styleid=2615"></iframe></td>
<td align="right"><iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="468" height="60" src="http://spcode.baidu.com/spcode/spstyle/style2475.jsp?tn=zhengbi_sp&ctn=0&styleid=2475"></iframe></td>
</tr>
</table></td>
</tr>
<tr>
<td height="14" background="images/index5_31.gif"></td>
</tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="40">您当前位置:<a href="">网站首页</a> >> <a href="article/list_107_1.html">网页制作</a> >> <a href="article/list_132_1.html">Javascript/Ajax</a> >> 阅读文章</td>
<form id="form1" name="form1" method="get" action="search.asp">
<td width="344"><span style="font-weight: bold">站内查找:</span>
<input name="keyword" type="text" id="keyword" size="29" />
<input type="submit" name="Submit" value="搜索" />
</td>
</form>
</tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><table width="100%" border="0" cellpadding="8" cellspacing="0" style="border:1px solid #AEE1DC;">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
<tr>
<td align="center"><h1>Ajax文本框输入提示</h1>
<hr size="1" color="#EBEBEB" />
来源:互联网 发布时间:2009-05-01 00:31:29 查看次数:<span id="News_Hits"></span><iframe style="display:none;" src="hits.asp?type=news&id=104"></iframe>
<hr size="1" color="#EBEBEB" />
</td>
</tr>
<tr>
<td style="word-break: break-all; word-wrap:break-word;"><div class="gray14"><P>一个Ajax文本框输入提示的例子,用asp实现:</P>
<P>前台文件</P><PRE><OL class=dp-xml><LI class=alt><SPAN><SPAN><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN></SPAN><LI><SPAN class=tag><</SPAN><SPAN class=tag-name>html</SPAN><SPAN> </SPAN><SPAN class=attribute>xmlns</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"http://www.w3.org/1999/xhtml"</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag><</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI><SPAN class=tag><</SPAN><SPAN class=tag-name>meta</SPAN><SPAN> </SPAN><SPAN class=attribute>http-equiv</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"Content-Type"</SPAN><SPAN> </SPAN><SPAN class=attribute>content</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"text/html; charset=utf-8"</SPAN><SPAN> </SPAN><SPAN class=tag>/></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag><</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></SPAN><SPAN>文本框输入提示</SPAN><SPAN class=tag></</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI><SPAN class=tag><</SPAN><SPAN class=tag-name>style</SPAN><SPAN> </SPAN><SPAN class=attribute>type</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"text/css"</SPAN><SPAN class=tag>></SPAN><SPAN>... </SPAN><LI class=alt><SPAN><!-- </SPAN><LI><SPAN>.keyword {...}{width:150px; height:20px; border:#0066FF 1px solid;}/**//*文本框样式*/ </SPAN><LI class=alt><SPAN>#keytishi {...}{width:150px; height:auto; border:#0066FF 1px solid; position:absolute; display:none;}/**//*提示层样式*/ </SPAN><LI><SPAN>#keytishi ul {...}{ margin:0;}/**//*提示层样式*/ </SPAN><LI class=alt><SPAN>#keytishi ul li{...}{margin:0;list-style-type:none; line-height:16px; height:16px; font-size:12px; padding:2px;}/**//*提示层样式*/ </SPAN><LI><SPAN>#keytishi ul li a {...}{display:block; width:150px; height:16px; text-decoration:none;}/**//*提示层样式*/ </SPAN><LI class=alt><SPAN>#keytishi ul li a:hover {...}{background-color:#0099FF;}/**//*提示层样式*/ </SPAN><LI><SPAN>--</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag></</SPAN><SPAN class=tag-name>style</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI><SPAN class=tag><</SPAN><SPAN class=tag-name>script</SPAN><SPAN> </SPAN><SPAN class=attribute>type</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"text/javascript"</SPAN><SPAN class=tag>></SPAN><SPAN>... </SPAN><LI class=alt><SPAN><!-- </SPAN><LI><SPAN> </SPAN><LI class=alt><SPAN>//建立XMLHttpRequest对象 </SPAN><LI><SPAN>var xmlhttp; </SPAN><LI class=alt><SPAN>try...{ </SPAN><LI><SPAN> </SPAN><SPAN class=attribute>xmlhttp</SPAN><SPAN>= </SPAN><SPAN class=attribute-value>new</SPAN><SPAN> ActiveXObject('Msxml2.XMLHTTP'); </SPAN><LI class=alt><SPAN>}catch(e)...{ </SPAN><LI><SPAN> try...{ </SPAN><LI class=alt><SPAN> </SPAN><SPAN class=attribute>xmlhttp</SPAN><SPAN>= </SPAN><SPAN class=attribute-value>new</SPAN><SPAN> ActiveXObject('Microsoft.XMLHTTP'); </SPAN><LI><SPAN> }catch(e)...{ </SPAN><LI class=alt><SPAN> try...{ </SPAN><LI><SPAN> </SPAN><SPAN class=attribute>xmlhttp</SPAN><SPAN>= </SPAN><SPAN class=attribute-value>new</SPAN><SPAN> XMLHttpRequest(); </SPAN><LI class=alt><SPAN> }catch(e)...{} </SPAN><LI><SPAN> } </SPAN><LI class=alt><SPAN>} </SPAN><LI><SPAN> </SPAN><LI class=alt><SPAN>function getKeyWord()...{ </SPAN><LI><SPAN> var </SPAN><SPAN class=attribute>obj</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>document</SPAN><SPAN>.getElementById("search");//获取文本域对象 </SPAN><LI class=alt><SPAN> if(</SPAN><SPAN class=attribute>obj.value</SPAN><SPAN>=="")...{ </SPAN><LI><SPAN> return; </SPAN><LI class=alt><SPAN> } </SPAN><LI><SPAN> var </SPAN><SPAN class=attribute>top</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>0</SPAN><SPAN>; </SPAN><LI class=alt><SPAN> var </SPAN><SPAN class=attribute>left</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>0</SPAN><SPAN>; </SPAN><LI><SPAN> while(obj)...{//此循环得到文件域对象在页面中的绝对位置 </SPAN><LI class=alt><SPAN> top += obj["offsetTop"]; </SPAN><LI><SPAN> left += obj["offsetLeft"]; </SPAN><LI class=alt><SPAN> </SPAN><SPAN class=attribute>obj</SPAN><SPAN class=attribute-value>obj</SPAN><SPAN> = obj.offsetParent; </SPAN><LI><SPAN> } </SPAN><LI class=alt><SPAN> xmlhttp.open("get","input.asp?</SPAN><SPAN class=attribute>keyword</SPAN><SPAN>="+document.getElementById("</SPAN><SPAN class=attribute-value>search</SPAN><SPAN>").value,true); </SPAN><LI><SPAN> </SPAN><SPAN class=attribute>xmlhttp.onreadystatechange</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>function</SPAN><SPAN>()...{ </SPAN><LI class=alt><SPAN> if(</SPAN><SPAN class=attribute>xmlhttp.readyState</SPAN><SPAN> == 4) </SPAN><LI><SPAN> ...{ </SPAN><LI class=alt><SPAN> if(</SPAN><SPAN class=attribute>xmlhttp.status</SPAN><SPAN> == 200) </SPAN><LI><SPAN> ...{ </SPAN><LI class=alt><SPAN> if(xmlhttp.responseText!="")...{ </SPAN><LI><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.innerHTML</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>unescape</SPAN><SPAN>(xmlhttp.responseText);//把后台返回的数据填充到提示层 </SPAN><LI class=alt><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.style.left</SPAN><SPAN> = left + "px";//设置提示层的位置,左 </SPAN><LI><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.style.top</SPAN><SPAN> = (top + 25) + "px";//设置提示层的位置,上 </SPAN><LI class=alt><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.style.display</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>"block"</SPAN><SPAN>;//设置提示层可见 </SPAN><LI><SPAN> }else...{ </SPAN><LI class=alt><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.innerHTML</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>""</SPAN><SPAN>;//清空提示层 </SPAN><LI><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.style.display</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>"none"</SPAN><SPAN>;//设置提示层不可见 </SPAN><LI class=alt><SPAN> } </SPAN><LI><SPAN> } </SPAN><LI class=alt><SPAN> else...{ </SPAN><LI><SPAN> </SPAN><LI class=alt><SPAN> } </SPAN><LI><SPAN> } </SPAN><LI class=alt><SPAN> } </SPAN><LI><SPAN> xmlhttp.setRequestHeader("If-Modified-Since","0"); </SPAN><LI class=alt><SPAN> xmlhttp.send(null); </SPAN><LI><SPAN>} </SPAN><LI class=alt><SPAN>function input(str)...{ </SPAN><LI><SPAN> document.getElementById("search")</SPAN><SPAN class=attribute>.value</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>str</SPAN><SPAN>;//从提示层选择你需要的数据填充到文本框 </SPAN><LI class=alt><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.innerHTML</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>""</SPAN><SPAN>;//清空提示层 </SPAN><LI><SPAN> document.getElementById("keytishi")</SPAN><SPAN class=attribute>.style.display</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>"none"</SPAN><SPAN>;//设置提示层不可见 </SPAN><LI class=alt><SPAN>} </SPAN><LI><SPAN>//--</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag></</SPAN><SPAN class=tag-name>script</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI><SPAN class=tag></</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag><</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI><SPAN class=tag><</SPAN><SPAN class=tag-name>input</SPAN><SPAN> </SPAN><SPAN class=attribute>type</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"text"</SPAN><SPAN> </SPAN><SPAN class=attribute>class</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"keyword"</SPAN><SPAN> </SPAN><SPAN class=attribute>id</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"search"</SPAN><SPAN> </SPAN><SPAN class=attribute>name</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"search"</SPAN><SPAN> </SPAN><SPAN class=attribute>onkeyup</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"getKeyWord();"</SPAN><SPAN> </SPAN><SPAN class=attribute>onclick</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"getKeyWord();"</SPAN><SPAN> </SPAN><SPAN class=tag>/></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag><</SPAN><SPAN class=tag-name>div</SPAN><SPAN> </SPAN><SPAN class=attribute>id</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"keytishi"</SPAN><SPAN class=tag>></SPAN><SPAN class=tag></</SPAN><SPAN class=tag-name>div</SPAN><SPAN class=tag>></SPAN><SPAN class=comments><!--提示层--></SPAN><SPAN> </SPAN><LI><SPAN class=tag></</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag></</SPAN><SPAN class=tag-name>html</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN></LI></OL></PRE>
<P>后台文件 [input.asp]</P><PRE><OL class=dp-xml><LI class=alt><SPAN><SPAN class=tag><</SPAN><SPAN>%...@</SPAN><SPAN class=attribute>LANGUAGE</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"VBSCRIPT"</SPAN><SPAN> </SPAN><SPAN class=attribute>CODEPAGE</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"65001"</SPAN><SPAN>%</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN></SPAN><LI><SPAN class=comments><!--#include file="conn.asp"--></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag><</SPAN><SPAN>%... </SPAN><LI><SPAN> dim rs </SPAN><LI class=alt><SPAN> dim sql </SPAN><LI><SPAN> </SPAN><LI class=alt><SPAN> dim keyWords </SPAN><LI><SPAN> </SPAN><LI class=alt><SPAN> </SPAN><SPAN class=attribute>keyWrods</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>Request</SPAN><SPAN>("keyword") </SPAN><LI><SPAN> </SPAN><LI class=alt><SPAN> Set </SPAN><SPAN class=attribute>rs</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>Server</SPAN><SPAN>.CreateObject("ADODB.Recordset") </SPAN><LI><SPAN> </SPAN><SPAN class=attribute>sql</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>"select * from king_test where keyword like '%"</SPAN><SPAN>&keyWrods&"%'" </SPAN><LI class=alt><SPAN> rs.open sql,conn,1,1 </SPAN><LI><SPAN> if not (rs.bof and rs.eof) then </SPAN><LI class=alt><SPAN> Response.Write("</SPAN><SPAN class=tag><</SPAN><SPAN class=tag-name>ul</SPAN><SPAN class=tag>></SPAN><SPAN>") </SPAN><LI><SPAN> do while not rs.eof </SPAN><LI class=alt><SPAN>%</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI><SPAN class=tag><</SPAN><SPAN class=tag-name>li</SPAN><SPAN class=tag>></SPAN><SPAN class=tag><</SPAN><SPAN class=tag-name>a</SPAN><SPAN> </SPAN><SPAN class=attribute>href</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>"javascript:void(null);"</SPAN><SPAN> </SPAN><SPAN class=attribute>onclick</SPAN><SPAN>="input('</SPAN><SPAN class=tag><</SPAN><SPAN>%Response.Write(escape(rs("keyword</SPAN><SPAN class=attribute-value>")))%>');"</SPAN><SPAN class=tag>></SPAN><SPAN class=tag><</SPAN><SPAN>%...Response.Write(escape(rs("keyword")))%</SPAN><SPAN class=tag>></SPAN><SPAN class=tag></</SPAN><SPAN class=tag-name>a</SPAN><SPAN class=tag>></SPAN><SPAN class=tag></</SPAN><SPAN class=tag-name>li</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN><LI class=alt><SPAN class=tag><</SPAN><SPAN>%... </SPAN><LI><SPAN> rs.movenext </SPAN><LI class=alt><SPAN> loop </SPAN><LI><SPAN> Response.Write("</SPAN><SPAN class=tag><</SPAN><SPAN class=tag-name>ul</SPAN><SPAN class=tag>></SPAN><SPAN>") </SPAN><LI class=alt><SPAN> end if </SPAN><LI><SPAN> rs.close </SPAN><LI class=alt><SPAN> set </SPAN><SPAN class=attribute>rs</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>nothing</SPAN><SPAN> </SPAN><LI><SPAN> conn.close </SPAN><LI class=alt><SPAN> Set </SPAN><SPAN class=attribute>conn</SPAN><SPAN> = </SPAN><SPAN class=attribute-value>nothing</SPAN><SPAN> </SPAN><LI><SPAN>%</SPAN><SPAN class=tag>></SPAN><SPAN> </SPAN></LI></OL></PRE>
<P>escape与unescape是用来编码的和解码的,这是为了避免汉字出现乱码,在XP + IE6,7,Firefox测试通过<BR></P></div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="5" style="border:1px solid #EBEBEB; margin-top:8px;">
<tr>
<td class="gray14">·<a href="article/105.html">上一条:AJAX的类库中使用服务接口定义[ASP.NET]</a><br />·<a href="article/103.html">下一条:AJAX应用中使用TODO服务[ASP.NET]</a></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="8" style="border:1px solid #EBEBEB; margin-top:8px;">
<tr>
<td bgcolor="#f2f6fb" class="black14b">相关文章</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="5" style="border:1px solid #EBEBEB; margin-top:4px;">
<tr>
<td class="gray14">·<a href="article/109.html" title="Ajax是什么">Ajax是什么</a> <font color="#999999">2009-05-01 00:43:25</font><br />
·<a href="article/108.html" title="Ajax 技术从入门到精髓">Ajax 技术从入门到精髓</a> <font color="#999999">2009-05-01 00:40:32</font><br />
·<a href="article/107.html" title="最基本的AJAX框架的实现方法">最基本的AJAX框架的实现方法</a> <font color="#999999">2009-05-01 00:38:02</font><br />
·<a href="article/106.html" title="AJAX调用WCF服务项模板[ASP.NET]">AJAX调用WCF服务项模板[ASP.NET]</a> <font color="#999999">2009-05-01 00:35:24</font><br />
·<a href="article/105.html" title="AJAX的类库中使用服务接口定义[ASP.NET]">AJAX的类库中使用服务接口定义[ASP.NET]</a> <font color="#999999">2009-05-01 00:34:14</font><br />
·<a href="article/104.html" title="Ajax文本框输入提示">Ajax文本框输入提示</a> <font color="#999999">2009-05-01 00:31:29</font><br />
·<a href="article/103.html" title="AJAX应用中使用TODO服务[ASP.NET]">AJAX应用中使用TODO服务[ASP.NET]</a> <font color="#999999">2009-05-01 00:30:32</font><br />
·<a href="article/101.html" title="Web2.0网站攻击新潮—Ajax Hacking">Web2.0网站攻击新潮—Ajax Hacking</a> <font color="#999999">2009-05-01 00:20:36</font><br />
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="8" style="border:1px solid #EBEBEB; margin-top:8px;">
<tr>
<td bgcolor="#f2f6fb" class="black14b">文章评论</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="3" style="border:1px solid #EBEBEB; margin-top:4px;">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="5">
<form id="form2" name="form2" method="post" action="save.asp">
<script language="JavaScript" type="text/javascript">
String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, "");}
function Ok3w_G_Submit(frm)
{
if(frm.UserName.value.trim()=="" || frm.UserName.value=="请输入您的姓名")
{
alert("请输入姓名");
frm.UserName.focus();
return false;
}
if(frm.Content.value.trim()=="" || frm.Content.value=="请输入您的评论")
{
alert("请输入内容");
frm.Content.focus();
return false;
}
frm.bntSubmit.disabled=true;
frm.submit();
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -