Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6138427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:52:06+00:00 2026-05-23T17:52:06+00:00

I have a little problem. I want to do automatic searching, but there is

  • 0

I have a little problem. I want to do automatic searching, but there is a difference between the results from my webrequest (automatic) and the results if I just hit enter.

I want to results to be the exactly the same, the result should be the one I get when I hit enter.

Code request:

function showUser(str, str2)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
} 
xmlhttp.open("GET", "klanttabel.php?search=" + encodeURIComponent(str) + "&search2=" +       encodeURIComponent(str), true);
xmlhttp.send();
}

Code query (wich gives me the right results)

if($search != ''){

$where[] = "( klant_id LIKE '%" .$search."%' OR  voornaam LIKE '%" .$search."%' OR     achternaam LIKE '%" .$search."%' OR email LIKE '%"        .$search."%' OR plaats LIKE '%"   .$search."%' OR bedrijfsnaam LIKE '%" .$search."%' ) ";

if($search2 != ''){
$where[] = " ( klant_id LIKE '%" .$search2."%' OR voornaam   LIKE '%" .$search2."%' OR   achternaam LIKE '%" .$search2."%' OR email LIKE '%" .$search2."%' OR   plaats LIKE '%"   .$search2."%' OR bedrijfsnaam LIKE '%" .$search2."%') ";
}
$query_where = (is_array($where))?" WHERE ".implode(" AND ", $where):""; 
$result = mysql_query("SELECT * FROM klant ".$query_where." ORDER BY klant_id DESC");
$i = 0;
}

I have two input fields, so that you can search for two different values. When I type them in and hit enter, it gives me the corresponding result.

But if I let it do it automatically, it just gives the result from the last field I typed in to.

So basically, it just searches for the last field. I think it has something to do with my input fields, so here is the code for that:

<form method="get">
<input onfocus="this.value=''" type="text" name="search" value="Naam..."    onkeyup="showUser(this.value)"></input><br />

<input onfocus="this.value=''" type="text" name="search2" value="Plaats..."  onkeyup="showUser(this.value)"></input><input type="submit" value="zoeken" name="submit2"   </input></form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:52:07+00:00Added an answer on May 23, 2026 at 5:52 pm

    A more elegant solution instead of using native XMLHttpRequests and all other workarounds is jQuery.ajax. Also, other things:

    • Input elements don’t have a closing </input>.

    A modified example that works on jsFiddle: http://jsfiddle.net/e9drS/.

    HTML:

    <form id="form">
        <input type="text" id="search" name="search" value="Naam..." />
    
        <br />
    
        <input type="text" id="search2" name="search2" value="Plaats..." />
    
        <input type="submit" value="zoeken" />
    </form>
    

    JavaScript:

    $(function() {
    
    $('#search, #search2').focus(function() { // clear on focus
        $(this).val('');
    }).keyup(function() { // perform request on keyup
        $.ajax({ type: 'GET',
                 url:  'klanttabel.php',
                 data: { search:  $('#search').val(),
                         search2: $('#search2').val() },
                 success: function(text) {
                     $("#txtHint").html(text);
                 }
               });
    });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem. I want to pass two variables from PHP to
I have a little problem, I have an array and I want to add
I have a litte problem here. I want to join twice from the same
I have a little problem with a navigation I'm making. I want my navigation
I have a little problem. I want to use Helvetica Neue 75 Bold in
Well I have a little problem. I want to get the sum of all
I have a little problem with a regex. I want to find in my
I have a little problem in my code. The variables don't want to change
I have a little problem: I want to solve this problem with OCaml, so
I have a little, but nasty problem: I have a database with many records,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.