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 9144171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:12:15+00:00 2026-06-17T10:12:15+00:00

I have created a simple text input box that will be used to fetch

  • 0

I have created a simple text input box that will be used to fetch data from a databse using ajax.

<form method="post" action="">
        <input type="text" id="txt1" onkeyup="showHint(this.value);" />
</form>

The textbox calls an ajax function called showHint(str) in my ajax.js file as follows:

function showHint(str){

var xmlhttp;
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
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","index.php?page=getList&q="+str,true);
xmlhttp.send();

}

As you can tell from the above script it opens my PHP script that is used to fetch details from the databse like so:

    //get the q parameter from URL
$q = $_GET["q"];

$sql = "SELECT Name FROM Country WHERE Name LIKE '" . $q . "%'";

$recordSet = $_dbConn->query($sql);
$a = $recordSet->getrow();

 //lookup all hints from array if length of q>0
 if (strlen($q) > 0)
   {
   $hint="";
   for($i=0; $i<count($a); $i++)
     {
     if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
       {
       if ($hint=="")
         {
         $hint=$a[$i];
         }
       else
         {
         $hint=$hint." , ".$a[$i];
         }
       }
     }
   }

 // Set output to "no suggestion" if no hint were found
 // or to the correct values
 if ($hint == "")
   {
   $response="no suggestion";
   }
 else
   {
   $response=$hint;
   }

 //output the response
 echo $response;

The issue is that I am using a single Index.php page and so this line: “index.php?page=getList&q=”+
is kinda like saying http://www.mydomain.com/index.php?index.php?page=getLet$q.

how can i fix this? I have tried to use POST and still not working. i have also tried to erase the index.php part in JS and that wont work either… thank you

  • 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-06-17T10:12:17+00:00Added an answer on June 17, 2026 at 10:12 am

    as per @lethal-guitar – xmlhttp.open(“GET”,”/index.php?page=getList&q=”+str,true);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been asked to create a simple calculations page that will have simple text
I have created an Ajax enabled WCF web service that contains this simple method:
So let's say I have jQuery convert a simple text input from this <input
I have a simple ASP.Net MVC View which contains an FCKeditor text box (created
I want to create a simple gsp page which will have an input box
Could someone help me on this, I have created simple web services using axis2
I have created this simple program to learn shared_ptr using namespace std; #define Yes
I have a simple search text box. This text box acts as a filter.
I'm trying to create a simple login system that will have the forms and
I have a jQuery UI Dialog Box that contains a jQuery UI Autocomplete input

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.