标题:脚本回车问题!
只看楼主
sm105096496
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2007-7-11
 问题点数:0 回复次数:1 
脚本回车问题!

我有一个脚本 有一个是 文本框 我输入了东西 点击 搜索 就能搜索了 但是我 怎么才能 在文本框输入后 按回车 也立即 搜索 应该怎么加...
下面是我的 脚本,
<td align="center"><select name="s2" id="s2" style="FONT-SIZE:8pt;">
<option value="Shw">推荐店家</option>
<option value="Lifefind">推荐菜品</option>
</select></td>
<td align="center" style="padding-bottom: 0px"><input type="text" name="txt" ID="Text1" maxlength="15" size="8" style="height:14px"></td>
<td width="50"><a href="javascript:to('Lifescout.aspx','Text1','s2')">搜索</a></td>

<script language="javascript">
function to(LinkUrl,textid,selectid)
{

var txtValue=window.document.getElementById(textid).value;
if(txtValue=="" )
{

alert("搜索不能为空!");
}
else
{
var bb=document.getElementById(selectid);
var aa = bb.options[bb.selectedIndex].value;

var txt = LinkUrl+"?o="+aa+"&name="+window.encodeURIComponent(txtValue);
window.location.href=txt;

}
}
</script>

搜索更多相关主题的帖子: 回车 脚本 
2007-08-20 16:11
followmephoe
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2006-9-5
得分:0 

代码如下:
<td align="center"><select name="s2" id="s2" style="FONT-SIZE:8pt;">
<option value="Shw">推荐店家</option>
<option value="Lifefind">推荐菜品</option>
</select></td>
<td align="center" style="padding-bottom: 0px"><input type="text" name="txt" ID="Text1" maxlength="15" size="8" style="height:14px" onkeydown="if(event.keyCode==13) aa();"></td>
<td width="50"><a href="javascript:to('Lifescout.aspx','Text1','s2')">搜索</a></td>

<script language="javascript">
function aa(){
alert('123213');
}
function to(LinkUrl,textid,selectid)
{

var txtValue=window.document.getElementById(textid).value;
if(txtValue=="" )
{

alert("搜索不能为空!");
}
else
{
var bb=document.getElementById(selectid);
var aa = bb.options[bb.selectedIndex].value;

var txt = LinkUrl+"?o="+aa+"&name="+window.encodeURIComponent(txtValue);
window.location.href=txt;

}
}
</script>

2007-08-21 09:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-164110-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.648977 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved