This may not be the most elegant solution, and is untested since it's just off the top of my head, but i wouldn't see why it wouldn't at least "work", heh
var _CurrentFieldName; $(document).ready(function() { $(".autocomlete") .focus(function() { _CurrentFieldName = $ (this).attr("name"); }) .autocomplete(url, { extraParams: { fieldname: _CurrentFieldName; } } }); }); On Oct 16, 8:59 am, 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.