Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2013
    Posts
    32
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Search with button

    Hello, can anyone help to make this script work with button? Now when i type some text in to search panel i must click ENTER...
    PHP Code:
            <script type="text/javascript"
                $(
    document).ready(function() {
                    $(
    '#search').keypress(function(x){if(x.keyCode==13){q=$(this).val();if(q!=this.defaultValue){document.location='/search/'+escape(q)}}});
                    $(
    '#search').focus(function(){if($(this).val()==this.defaultValue)$(this).val('')});
                    $(
    '#search').blur(function(){if($(this).val()=='')$(this).val(this.defaultValue)});
                    
                    $(
    '.button, .avatar').tipsy({gravity:'n'fade:1htmltrueopacity1});
                });
            
    </script> 
    PHP Code:
    <input id="search" type="text" value="search word" type="text" /> 
    Sorry for my poor english.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,197
    Thanks
    23
    Thanked 605 Times in 604 Posts
    $('#search') looks for an action from the <input> If you want a button to make things work turn this into The Button ID.

    All top lines work on an action from the search box; keypress, focus, and blur. Further more if(x.keyCode==13) is the keyboard enter code.

    You need to rewrite all of this.

  • #3
    New Coder
    Join Date
    Feb 2013
    Posts
    32
    Thanks
    10
    Thanked 0 Times in 0 Posts
    can anyone edit this code for me?
    Sorry for my poor english.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •