You are absolutely right! it worked.
The only thing is i cannot highlight on individual result. If i click on a
select, the result from the database is taken.

Do you know how to make sure i can hover on a single result and select?

Thanks

On Wed, Mar 11, 2009 at 4:57 PM, MorningZ <morni...@gmail.com> wrote:

>
> the characters the user types in is already added to the request to
> the "test.php" file and is query string parameter "q"
>
> if you fire up a tool like Firebug (for FireFox) or Fiddler (for IE)
> and you'll see this happening in real time
>
>
>
>
> On Mar 11, 12:35 pm, Bright Dadson <brightdad...@googlemail.com>
> wrote:
> > You right!
> >
> > Quick question though! Do you know how i can make the script pass the
> > character i type to be passed to the php script which intend return the
> > search result matching the character in the textbox?
> >
> > I have type done something like this;
> >
> > echo "Operator"; in my php and that is all i see when i start typing in
> the
> > textbox but anything relating to the resultset.
> >
> > Do i need to customize the jQuery further to achieve this or the php
> results
> > needs bit more formating?
> >
> > pls hlp
> >
> > On Wed, Mar 11, 2009 at 3:59 PM, MorningZ <morni...@gmail.com> wrote:
> >
> > > Those examples don't make any sense
> >
> > > the first one
> >
> > > $("example").html(data);
> >
> > > the input box will already be filled with the "data" (which keep in
> > > mind is what the user selected)
> >
> > > the second one
> >
> > > data = $("example").text;
> >
> > > the value of "data" is what the user selected and will already be
> > > inside the <input> box that is ID'd "example"
> >
> > > Only use the ".result" event if you need to do something above and
> > > beyond what the base functionality is
> >
> > > As for your issue, i'd take a guess your results back from the php
> > > page aren't what the plugin is expecting, a tool like Firebug or
> > > Fiddler will show you exactly (1) what's being sent to "test.php" and
> > > (2) what's being returned to the page from "test.php"
> >
> > > On Mar 11, 11:47 am, Bright Dadson <brightdad...@googlemail.com>
> > > wrote:
> > > > I have done something like this;
> >
> > > >         <script>
> > > >             $(document).ready(function(){
> > > >                 $("#example").autocomplete(
> > > >                 "test.php"
> > > >             ).result(function(a,data,c) {
> > > >                     // variable "data" has the value the user
> selected
> > > >                     $("example").html(data);
> > > >                 });
> > > >             });
> > > >         </script>
> >
> > > > and also something like this;
> >
> > > >         <script>
> > > >             $(document).ready(function(){
> > > >                 $("#example").autocomplete(
> > > >                 "test.php"
> > > >             ).result(function(a,data,c) {
> > > >                     // variable "data" has the value the user
> selected
> > > >                     data = $("example").text;
> > > >                 });
> > > >             });
> > > >         </script>
> >
> > > > But still donot see the suggestion for autocomplete from the php, is
> > > > anything i am not considering? please help i am really a begininer in
> > > this.
> >
> > > > my php now looks like this:
> >
> > > > <?php
> > > > $q=$_GET["q"];
> >
> > > > $con = mysql_connect('host', 'user', 'password');
> > > > if (!$con)
> > > > {die('Could not connect: ' . mysql_error());}
> >
> > > > mysql_select_db("tvoc", $con);
> > > > $result = mysql_query("SELECT company_name FROM operator WHERE
> > > company_name
> > > > = '$q'");
> > > > if (!$result) {
> > > >     echo 'Did not get matching result: ' . mysql_error();
> > > >     exit;}else{
> >
> > > >     $row = mysql_fetch_row($result);
> > > >     echo $row[10];}
> >
> > > > ?>
> >
> > > > On Wed, Mar 11, 2009 at 3:36 PM, Joseph Le Brech <
> jlebr...@hotmail.com
> > > >wrote:
> >
> > > > >  you are assigning the html here to what's in data.
> >
> > > > > to access i think is data = $("example").text;
> >
> > > > > try this but breakpoint it in firebug, because in not using firefox
> > > right
> > > > > now.
> >
> > > > > ------------------------------
> > > > > Date: Wed, 11 Mar 2009 15:18:10 +0000
> > > > > Subject: [jQuery] Re: AutoComplete
> > > > > From: brightdad...@googlemail.com
> >
> > > > > To: jquery-en@googlegroups.com
> >
> > > > > Do i access "data" like this;
> >
> > > > >  $("example").html(data);
> >
> > > > > On Wed, Mar 11, 2009 at 3:11 PM, Joseph Le Brech <
> jlebr...@hotmail.com
> > > >wrote:
> >
> > > > > you should be sanitising your sql aswell.
> >
> > > > > > Date: Wed, 11 Mar 2009 08:00:23 -0700
> > > > > > Subject: [jQuery] Re: AutoComplete
> > > > > > From: morni...@gmail.com
> > > > > > To: jquery-en@googlegroups.com
> >
> > > > > > What is the purpose of the ".get()" ?
> >
> > > > > > The autocomplete plugin already has the ajax call all wired into
> it,
> > > > > > there's no need to do that on your own
> >
> > > > > > $(document).ready(function(){
> > > > > > $("#example").autocomplete(
> > > > > > "test.php"
> > > > > > ).result(function(a,data,c) {
> > > > > > // variable "data" has the value the user selected
> > > > > > });
> > > > > > });
> >
> > > > > > On Mar 11, 10:45 am, Bright Dadson <brightdad...@googlemail.com>
> > > > > > wrote:
> > > > > > > Hi Experts,
> >
> > > > > > > I am trying to use jQuery get function to develop an
> autocomplete
> > > which
> > > > > will
> > > > > > > display suggestion as soon as users starts typing like this;
> >
> > > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > > > > > > "http://www.w3.org/TR/html4/loose.dtd";>
> > > > > > > <html>
> > > > > > >     <head>
> > > > > > >         <script src="http://code.jquery.com/jquery-latest.js
> > > > > "></script>
> > > > > > >         <link rel="stylesheet" href="
> > > > >http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css
> "
> > > > > > > type="text/css" />
> > > > > > >         <link rel="stylesheet" href="
> > > > >
> http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomp..
> > > ."
> > > > > > > type="text/css" />
> > > > > > >         <script type="text/javascript" src="
> > > > >
> http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgif.
> > > ..
> > > > > > > "></script>
> > > > > > >         <script type="text/javascript" src="
> > > > >
> http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dime.
> > > ..
> > > > > > > "></script>
> > > > > > >         <script type="text/javascript" src="
> > > > >
> http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomp.
> > > ..
> > > > > > > "></script>
> > > > > > >         <script>
> > > > > > >             $(document).ready(function(){
> > > > > > >                 var result = $.get("test.php", { data:
> > > > > > > "q"+$("#example").attr('value') },
> > > > > > >                 function(data){
> > > > > > >                     $("#example").html(data);
> > > > > > >                 });
> >
> > > > > > >                 $("#example").autocomplete(result);
> > > > > > >             });
> > > > > > >         </script>
> >
> > > > > > >     </head>
> > > > > > >     <body>
> > > > > > >         Company name: <input id="example" />
> > > > > > >     </body>
> > > > > > > </html>
> >
> > > > > > > and my backend php script looks like this;
> >
> > > > > > > <?php
> > > > > > >      $q=$_GET["q"];
> > > > > > >       $con = mysql_connect('host', 'user', 'password');
> > > > > > >       if (!$con)
> > > > > > >        {
> > > > > > >           die('Could not connect: ' . mysql_error());
> > > > > > >       }
> >
> > > > > > >       mysql_select_db("database", $con);
> >
> > > > > > >        $sql="SELECT company_name FROM company WHERE
> company_name =
> > > > > > > '".$q."'";
> >
> > > > > > >      $result = mysql_query($sql);
> >
> > > > > > >          while($row = mysql_fetch_array($result))
> > > > > > >         {
> > > > > > >             echo $row['company_name'];
> > > > > > >           }
> >
> > > > > > > mysql_close($con);
> > > > > > > ?>
> >
> > > > > > > Unfurtunately tthis donot work as required - i donot see any
> > > > > suggestion. Do
> > > > > > > anyone know what i am doing wrong here?
> >
> > > > > > > Pls help.
> >
> > > > >  ------------------------------
> > > > > Windows Live Hotmail just got better. Find out more!<
> > >http://clk.atdmt.com/UKM/go/134665311/direct/01/>
> >
> > > > > ------------------------------
> > > > > Windows Live Hotmail just got better. Find out more!<
> > >http://clk.atdmt.com/UKM/go/134665311/direct/01/>
>

Reply via email to