每个按下的字母都会提交的文本框
我有一个 php 搜索引擎,我想要一个 java 脚本文本框,它会在按下每个字母时提交。我想要的效果是Google Instant。我的网站很简单,所以速度会很快。
<form method='post' action='?&id=search' name='form' >
Search:<br>
<input name='search' value='<?php echo "$sq"; ?>' type='text' class='form2' style='font-weight:bold;' size='25' onUnfocus='send()'>
<input type='submit' class='button' value='Search'>
谢谢你,非常非常
I have a php search engine and i want a java scripted text box that submits on every letter pressed. The effect that i want is the Google instant. My site is simple so it will go fast.
<form method='post' action='?&id=search' name='form' >
Search:<br>
<input name='search' value='<?php echo "$sq"; ?>' type='text' class='form2' style='font-weight:bold;' size='25' onUnfocus='send()'>
<input type='submit' class='button' value='Search'>
thank you, very very much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
jQuery
jQuery
从您提交的代码来看,我假设它有效,但不适用于按下的每个键,因为您需要使用 onkeyup 或 onchange
Judging from your submitted code, I'm gonna assume it works, but not for every key pressed, because you need to use either onkeyup or onchange
使用标准表单提交方法将重新加载页面。您需要使用 AJAX 提交表单数据并动态更新结果。
unFocus
也不是一个有效的事件(您正在考虑onblur
),但您想要的是onkeyup
。javascript 事件处理程序应发送表单数据,成功处理程序应更新结果。
Using a standard form submission method would reload the page. What you'll need is to submit the form data using AJAX and dynamically update the results.
unFocus
is also not a valid event (you are thinking ofonblur
) but what you want isonkeyup
.The javascript event handler should send the form data and the success handler should update the results.