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

  • SEARCH
  • Home
  • 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 6662927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:26:36+00:00 2026-05-26T02:26:36+00:00

First of all, I am new to Javascript. I need concrete help not only

  • 0

First of all, I am new to Javascript. I need concrete help not only explanations of what to do. Thx!

Description of the problem:

I have a text field which after the user starts typing in it, generates a drop down list with values out of the database….basically an auto complete function.

Based on the value in this text field, another process needs to be initiated using the value. But the problem is that the value is only what the user typed in the field, not what the user eventually picked out of the auto complete list.

example:

I type in “bo” and the auto complete list generates “boeing”. I click on boeing to fill in the field… but the value picked up is “bo”.

How can I capture the complete value and use it in an onChange event explained below?

The concrete stuff:

1)the fields:

<input type=\"text\" size=\"30\" name=\"manuList\"
    id=\"inputString\" value=\"$_POST[manu_prev]\" 
    onkeyup=\"lookup(this.value);\" onblur=\"fill();\" 
    onChange=\"htmlData('get_model.php', 'ch='+this.value)/>

<div class=\"suggestionsBox\" id=\"suggestions\" 
     style=\"display: none;\">
  <img src=\"/images/upArrow.png\" 
    style=\"position: relative; top: -12px; 
            left: 30px;\" alt=\"upArrow\" />
  <div class=\"suggestionList\" id=\"autoSuggestionsList\">
      &nbsp;</div>
</div>

2) the function htmlData needs the value of the field (onChange event), but as explained above, only what the user types is stored in this.value, not what gets picked from the list. I want to print the value picked by the user by this:
onChange=\”htmlData(‘get_model.php’, ‘ch=’+this.value)
But instead of printing the complete value “boeing” it will print “bo” which is what the user typed to generate the list.

function htmlData(url, qStr)
{
   if (url.length==0)
   {
       document.getElementById("txtResult").innerHTML="";
       return;
   }
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

   url=url+"?"+qStr;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}

The initiated php script “get_model.php” prints the value:

 echo $_GET['ch'];  

The other functions used for the auto complete:

function lookup(inputString)
{
  if(inputString.length == 0)
  {
    // Hide the suggestion box.
    $('#suggestions').hide();
  } else
  {
    $.post("rpc.php", {queryString: ""+inputString+""}, function(data)
    {
      if(data.length >0) 
      {
        $('#suggestions').show();
        $('#autoSuggestionsList').html(data);
      }
    });
  }
} // lookup

function fill(thisValue) 
{
  $('#inputString').val(thisValue);
  setTimeout("$('#suggestions').hide();", 200);
}

function GetXmlHttpObject(handler)
{
   var objXMLHttp=null
   if (window.XMLHttpRequest)
   {
       objXMLHttp=new XMLHttpRequest()
   }
   else if (window.ActiveXObject)
   {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
   }
   return objXMLHttp
}

function stateChanged()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
       document.getElementById("txtResult").innerHTML= xmlHttp.responseText;
   }
   else 
   {
       //alert(xmlHttp.status);
   }
}
  • 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-26T02:26:37+00:00Added an answer on May 26, 2026 at 2:26 am

    You need to listen to the event on the list you create – can you give an example of the output that fills the autoSuggestionsList

    For example it might be a list that is added by the following line :

    $('#autoSuggestionsList').html(data);

    that could give you

    <div class=\"suggestionList\" id=\"autoSuggestionsList\">
          <ul id="unOrderedList">
              <li value="2">Whatever</li>
              ......
          </ul>
    </div>
    

    you can then setup an event listener on the <li>‘s…

    $('#unOrderedList li').click(function(){
          var value = $(this).attr('value');
          // Do what every you want with the data.....
      });
    

    This would replace the onchange event on the input field

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

Sidebar

Related Questions

first of all I'm totally new to FAST but I already have a couple
First of all, let me say I am very new to rails, have been
All, I'm pretty new with JavaScript and this is my first attempt with the
Im new to Javascript and jquery and I almost have my problem solved. I
I'm new to web development and for my first project I have a need
First of all, im new here, and im (not) a pro ;) (but i
First of all, I'm kinda new to the barcode formats and what I do
First of all, I'm really new to the MVC Asp.Net ideology. I would like
First of all, I'm fairly new to Java, so sorry if this question is
I am new here so first of all my greetings to you I am

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.