Have you tried this?

$("input:text").focus( function() { alert($
(this).attr("name")); } ).autocomplete("server.php", {
                      extraParams: {
                       fieldname: function() { return $(this).attr("name"); }
                   }
});

It assign the autocomplete function to every focused input. You have
to filter here $("input:text") to assign it only to your required
fields.

Hope it works.

Cheers

On Oct 16, 1:59 pm, The Hamburgler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I wish to pass an extra parameter to the Autocomplete query URL that
> will determine the name of the current input field. The URL will then
> know what field is requesting the data and can return the relevant
> data.
> E.g. It could be list of countries or a group of surnames already in
> the database.
>
> I have read the documentation and thought the extraParams option would
> do this but i'm struggling with the correct syntax.
>
> The example below will pass an undefined value for 'fieldname' as $
> (this) is out of scope within the extraParams function. Is there a way
> I can access the inputs field name dynamically so i don't have to bind
> the autocomplete function to each individual input?
>
> $(".autocomlete").autocomplete(url, {
>    extraParams: {
>        fieldname: function() { return $(this).attr("name"); }
>    }
>
> });
>
> http://docs.jquery.com/Plugins/Autocomplete
>
> Thanks for your time.

Reply via email to