Hi Jorn,

I now have the following based on your suggestion to populate the
second input field:


$(document).ready(function(){

$("#lotno1").autocomplete("../js/autocomplete.php?SaleNo=102", {
                               matchContains: true,
                               mustMatch: true,
                       });

$("#descno1").autocomplete("../js/autocomplete.php?SaleNo=102", {
       extraParams: {
               first: function() {
                       return $("#lotno1").val();
               }
       }
       });
});


where 'autocomplete.php' looks like:

<?php require_once('../../../Connections/Oundle_DB.php'); ?>
<?php
$SaleNo = ($_GET["SaleNo"]);
$q = strtolower($_GET["q"]);

mysql_select_db($database_Oundle_DB, $Oundle_DB);
$query = "SELECT `LotNo`, `A`, `Description` FROM batemans WHERE
`SaleNo`
LIKE $SaleNo ORDER BY LotNo ASC";
$result = mysql_query($query, $Oundle_DB) or die(mysql_error());
while($row=mysql_fetch_assoc($result))
if (strpos(strtolower($row['LotNo']), $q) !== false) {
               echo ($row['LotNo'].$row['A'].'|'.
$row['Description'].'\r');
}
?>

You can view the page at:
http://www.batemans-auctions.co.uk/new_site/absentee_form.php

(first input box under 'Lot No' is where to type, any number between 1
and 500:

If I enter '1' the autocomplete does not return all values in the
mySQL field that
contain a '1', I thought adding matchContains: true, would fix this,
any ideas?

Also when clicking the value  from the drop down, it does not populate
the
second field (id= descno1) with the coresponding value from the
Description
column, any ideas?

Many thanks for your support.

Regards
Matt


On Aug 27, 1:05 am, VirusMinus <[EMAIL PROTECTED]> wrote:
> Hi Jorn,
>
> Is there a way to call a function when no results are returned by the
> input the user has typed into the autocomplete?
>
> This would be ideal as an option or a method for the autocomplete
> object.
>
> I've seen a few people ask for this on your site and also here. You
> mentioned including such functionality in a future release but I don't
> think it was done.
>
> Anyone mange to do this or have pointers on how I could go about
> implementing it myself?
>
> If I succeed maybe we can add this as a feature to the current build
> of autocomplete?
>
> Cheers,
> VM
>
> On Aug 27, 8:04 am, "Jörn Zaefferer" <[EMAIL PROTECTED]>
> wrote:
>
> > The download includes demo PHP scripts that you can look at. Or check
> > it online 
> > viahttp://dev.jquery.com/view/trunk/plugins/autocomplete/demo/search.phps
> > (linked fromhttp://jquery.bassistance.de/autocomplete/demo/)
>
> > Jörn
>
> > On Tue, Aug 26, 2008 at 10:11 PM, Mattl <[EMAIL PROTECTED]> wrote:
>
> > > Thanks Jörn,
> > > Is there a tutorial or demo that shows what the php file that queries
> > > the db should look like, or in what format the results need to be
> > > returned in?
>
> > > ie what does 'my_autocomplete_backend.php' look like?
>
> > > I've not been able to find one.
>
> > > Thanks in advance,
> > > Matt
>
> > > On Aug 25, 11:32 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
> > > wrote:
> > >> The autocomplete plugin
> > >> (http://plugins.jquery.com/project/autocompletex) can do that. Set the
> > >> one up as usual, and configure the other one with a dynamic extra
> > >> paramter:
>
> > >> $("#second").autocomplete("url", {
> > >>         extraParams: {
> > >>                 first: function() {
> > >>                         return $("#first").val();
> > >>                 }
> > >>         }
>
> > >> });
>
> > >> Jörn
>
> > >> On Mon, Aug 25, 2008 at 11:22 PM, Mattl <[EMAIL PROTECTED]> wrote:
>
> > >> > Hi,
> > >> > Anyone know of a jQuery plugin similar to the Autocomplete that could
> > >> > do the following?
>
> > >> > I have a mysql db with two columns, 'Lot No' and 'Description'.
>
> > >> > I have a form with two input fields, 'Lot No' and 'Description' and
> > >> > I'd like the 'Description' input field to be auto-populated from the
> > >> > database based on the entry the user puts into the 'Lot No' input
> > >> > field.
>
> > >> > ie if they typed in '1' into the 'Lot No' field then the 'Description'
> > >> > input field would call up the corresponding row entry to '1' from the
> > >> > database.
>
> > >> > Hope I've explained this clearly enough...
>
> > >> > Many thanks
> > >> > Matt

Reply via email to