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

  • Home
  • SEARCH
  • 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 8773819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:24:06+00:00 2026-06-13T18:24:06+00:00

Somewhere I found an autocomplete script which suits me perfectly, but there is one

  • 0

Somewhere I found an autocomplete script which suits me perfectly, but there is one thing that I don’t know how to change. When you click on something in dropdown it doesn’t submit this string, you have to click to select the string and after that click on submit button or press enter. I would like this dropdown autocomplete to submit selected string on click or when pressing enter. This is the code:

        <link rel="stylesheet" href="ac.css" />    
        <script src="./java/jquery182.js"></script>    
        <script src="./java/jqueryui.js"></script>    
        <script>    
        $(function() {        
        var availableTags = [            
        "Car",   
        "Gun",
        "Apple",
        "Example"]; 

         $( "#txt" ).autocomplete({            
         source: availableTags        
         }); 
         });   
         </script>

        <script type="text/javascript"> 
        <!-- 
        function enter(e){ 
        if(e.keyCode == 13) 
        { 
        doSomething(); 
        return false; 
        } 
        } 
        //--> 
        </script> 


<input class="ui-widget" id="txt" type="text" onkeypress="return enter(event);">
<button type="button" id="btn" onclick="doSomething()">Submit</button>

Function doSomething(); has to be there because I need it. This function: onkeypress="return enter(event);" is here so that when enter is pressed, value gets submitted to the doSomething(); function. There are 2 Javascript documents (jquery182.js and jqueryui,js) which have around 10,000 lines of code so I had to upload them here: http://speedy.sh/a67xR/java-files.zip Hope someone can help me with this.

  • 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-06-13T18:24:07+00:00Added an answer on June 13, 2026 at 6:24 pm

    You have to configure the onclick/select behaviour in the call to autocomplete, try this:

    $( "#txt" ).autocomplete({            
        source: availableTags,
        select: function(event, ui) {
            $(event.target).val(ui.item.value);
            doSomething();
            return false;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Objective-C code that I found somewhere. Honestly, I don't understand a
A few weeks ago I found somewhere a code that allows one to dump
I have a script that I found somewhere online that shows or hides divs
I have just started spring, I found that somewhere we are using handlerequest() method
I found the following code somewhere, but I am not understanding the code properly.
Somewhere here on Stack Overflow, I had found the following code some day which
I'm getting all my active special products using this code that I've found somewhere:
I used some script i found somewhere:(im a total svn noob, is it used
I am working on an app for Android OS. There is one thing, I
I'm making animation of moving window on desktop. I have found somewhere info that

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.