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 4 of 4
  1. #1
    Regular Coder MaDmiX's Avatar
    Join Date
    Feb 2012
    Location
    Charlotte, NC
    Posts
    201
    Thanks
    51
    Thanked 0 Times in 0 Posts

    Requery on text field change

    Hi All,

    I have some text fields on my page. I would like to requery my database columns as the user enters text into these fields (each field being for a different column). It would need to filter the records with each keystroke and if the user enters into more than one column it needs to filter based on all of the fields that have text in them.

    I know that I probably need to create a function that will be called on the onChange event for each text field and store the value in a variable but I can't figure out how to get the query to fire each time the function is called.

    Is PHP the best way to do this or can anyone offer some better alternatives? I appreciate any help.

    Thanks in advance.

    Ken

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This hasn't a thing to do with PHP. PHP's responsibility ends with the sending of the result to the client, and all communication is terminated. You must use AJAX to send requests in the background, in which case the PHP processes the request again as per a normal brand new request. So it doesn't matter if its done with AJAX or not, you simply handle the querystring request / post request as per a normal HTML request on the PHP end. If AJAX is in use, it handles both the sending and receiving of the request and parsing it for relevant data.

    You'll want to make sure you put a delay on there as well. If you run it in real time on each keystroke, you can potentially run hundreds of queries per minute against the database.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Google for autocomplete scripts.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    Regular Coder MaDmiX's Avatar
    Join Date
    Feb 2012
    Location
    Charlotte, NC
    Posts
    201
    Thanks
    51
    Thanked 0 Times in 0 Posts
    Thanks for the replies. This gets me going in the right direction.

    Ken


  •  

    Posting Permissions

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