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 3967670
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:44:51+00:00 2026-05-20T03:44:51+00:00

I am writing an autocomplete form with multiple types of data. In the HTML,

  • 0

I am writing an autocomplete form with multiple types of data.

In the HTML, data types are separated by using the key attribute:

<input type="text" name="data0" value="" size="20" id="data0" key="country"/>
<input type="text" name="data1" value="" size="20" id="data1" key="state"/>

In the js file, I run a wildcard selector on input and use the autocomplete this way:

$(function() {
$(":input").autocomplete({
    source: "query.php?type="+$(this).attr("key")+"&mode=1",
    minLength: 2
});
});

But it does not work.

I wondered if it is due to the .attr() selector, so I wrote another code to test it:

var test="state";
$(function() {
$(":input").autocomplete({
    source: "query.php?type="+test+"&mode=1",
    minLength: 2
});
});

does not work either.

Thank you in advance for the help!

edit:

$(function() {
$(":input").autocomplete({
    source: "query.php?type=state&mode=1",
    minLength: 2
});
});

this will work. So I am sure it is not a selector problem.

  • 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-20T03:44:52+00:00Added an answer on May 20, 2026 at 3:44 am
    $(function() {
    $(":input").autocomplete({
        source: "query.php?type="+$(this).attr("key")+"&mode=1",
        minLength: 2
    });
    });
    

    Will not work because this doesn’t point to what you think it does. You could do something like this…

    $(":input").each(function() {
       $(this).autocomplete({
        source: "query.php?type="+encodeURIComponent($(this).attr("key"))+"&mode=1",
        minLength: 2
       });
    });
    

    You also ought to encode the parameter above, as I have done for you.

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

Sidebar

Related Questions

For my acceptance testing I'm writing text into the auto complete extender and I
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
I writing a report in Visual Studio that takes a user input parameter and
I'm writing an ASP.NET MVC application and I have a form where a user
I am writing django templates in Eclipse->prefrences->templates, to autocomplete DJango templates. I wrote this
The .NET ComboBox autocomplete will not fully autocomplete with the display text contains a
I'm writing a simple script to autocomplete when I press TAB. The php script
I'm writing a greasemonkey script that creates an auto-complete search type box which makes
I am using jQuery UI Autocomplete to build a search interface. I have defined
Writing some test scripts in IronPython, I want to verify whether a window is

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.