用户在文本框中键入时,使用jquery提交表单发布事件

时间:2022-11-23 18:24:17

How do I postback whenever a user types in a textbox to filter results in a div tag.

每当用户键入文本框以过滤div标签中的结果时,如何回发。

3 个解决方案

#1


I think this is an interesting article for you:

我认为这是一篇有趣的文章:

jQuery Live Ajax Search Plug-in

jQuery Live Ajax Search Plug-in

#2


There are a couple of neat jQuery plugins that do exactly this. My favorite is jQuery LiveSearch but if you google jQuery AJAX search you'll find a bunch out there.

有几个巧妙的jQuery插件正是这样做的。我最喜欢的是jQuery LiveSearch,但如果你google jQuery AJAX搜索,你会发现一堆。

#3


<script language=javascript>
            $(document).ready(function() {
            $("#SearchBox").focus();
                $("#SearchBox").keyup(function(event) {
                    var e = window.event || e
                var keyunicode = e.charCode || e.keyCode
                //Allow alphabetical keys, plus BACKSPACE and SPACE
                if (keyunicode >= 65 && keyunicode <= 122 || keyunicode == 8 || keyunicode == 32) {
                    $("#SubBut").click();
                }

                });

            });

    function SetEnd(TB) {
                var FieldRange = TB.createTextRange();
                FieldRange.moveStart('character', TB.value.length);
                FieldRange.select();
            }  

        </script>

Add onfocus="SetEnd(this) to the properties of your search input control. This will set the caret to the end of the text.

将onfocus =“SetEnd(this)添加到搜索输入控件的属性中。这会将插入符号设置为文本的结尾。

This will only postback when an alphanumeric character is entered into the textbox, including delete.

只有在文本框中输入字母数字字符(包括删除)时才会回发。

Hope this helps someone.

希望这有助于某人。

Note I have only tested this on IE7 therefore some things may not work in Firefox or other browsers.

注意我只在IE7上测试了这个,因此有些东西可能在Firefox或其他浏览器中不起作用。

#1


I think this is an interesting article for you:

我认为这是一篇有趣的文章:

jQuery Live Ajax Search Plug-in

jQuery Live Ajax Search Plug-in

#2


There are a couple of neat jQuery plugins that do exactly this. My favorite is jQuery LiveSearch but if you google jQuery AJAX search you'll find a bunch out there.

有几个巧妙的jQuery插件正是这样做的。我最喜欢的是jQuery LiveSearch,但如果你google jQuery AJAX搜索,你会发现一堆。

#3


<script language=javascript>
            $(document).ready(function() {
            $("#SearchBox").focus();
                $("#SearchBox").keyup(function(event) {
                    var e = window.event || e
                var keyunicode = e.charCode || e.keyCode
                //Allow alphabetical keys, plus BACKSPACE and SPACE
                if (keyunicode >= 65 && keyunicode <= 122 || keyunicode == 8 || keyunicode == 32) {
                    $("#SubBut").click();
                }

                });

            });

    function SetEnd(TB) {
                var FieldRange = TB.createTextRange();
                FieldRange.moveStart('character', TB.value.length);
                FieldRange.select();
            }  

        </script>

Add onfocus="SetEnd(this) to the properties of your search input control. This will set the caret to the end of the text.

将onfocus =“SetEnd(this)添加到搜索输入控件的属性中。这会将插入符号设置为文本的结尾。

This will only postback when an alphanumeric character is entered into the textbox, including delete.

只有在文本框中输入字母数字字符(包括删除)时才会回发。

Hope this helps someone.

希望这有助于某人。

Note I have only tested this on IE7 therefore some things may not work in Firefox or other browsers.

注意我只在IE7上测试了这个,因此有些东西可能在Firefox或其他浏览器中不起作用。