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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:29:12+00:00 2026-05-13T16:29:12+00:00

So I have 2 inputs. Both are for an autocomplete. I also have 2

  • 0

So I have 2 inputs. Both are for an “autocomplete”. I also have 2 functions that do pretty much the same thing… Each input calls a different function onBlur. The problem is that the second upon selecting a “suggestion” for the second input, it populates the first. What can I do to make the second one populate the second?

There’s probably a better way of doing it but my jQuery/Javascript Knowledge is limited and I’m running out of time… Thanks!

The code:

function fillLocation(thisValue) {
    $('#location-box').val(thisValue);
    setTimeout("$('#suggestionsLocation').fadeOut('fast');", 200);
}

function fillTerms(thisValue) {
    $('#terms-box').val(thisValue);
    setTimeout("$('#suggestionsTerms').fadeOut('fast');", 200);
}


<input type="text" name="search_location" id="location-box" value="" onkeyup="suggestLocation(this.value);" onblur="fillLocation();" autocomplete="off" />

<input type="text" name="search_terms" id="terms-box" value="" onkeyup="suggestTerms(this.value);" onblur="fillTerms();" autocomplete="off" />
  • 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-13T16:29:13+00:00Added an answer on May 13, 2026 at 4:29 pm

    I guess I’m assuming you want to trigger keyup and blur events for both inputs that have similar functionality, and that will both in turn affect the same input.

    This would be one way. Bind the events in javascript, not HTML, and run the proper code

    $('document').ready(function() {
    
        $('#location-box,#terms-box')
                        .bind('keyup', function() {
                               // do your keyup thing using $(this)
                               // to refer back to the input
                               //$('body').append($(this).attr('id') + ': keyup<br />');
                               var theValue = $(this).val();
                         }) 
                         .bind('blur', function() {
                               // do your blur thing using $(this)
                               // to refer back to the input
                               //$('body').append($(this).attr('id') + ': blur<br />');
                         })
        });
    
    
    <input type="text" name="search_location" id="location-box" value="" autocomplete="off" />
    <input type="text" name="search_terms" id="terms-box" value="" autocomplete="off" />
    

    EDIT:

    Uncomment the $(‘body’) lines to see the events in action.

    Hope this is what you were looking for.

    EDIT: Added to code to the keyup event to retrieve the value

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

Sidebar

Related Questions

I have a form element that contains multiple lines of inputs. Think of each
I have a php script that handles a form input. For design reasons both
I have an input field where both regular text and sprintf tags can be
i have an input element, and i want bind both change and keypress event
We have some input data that sometimes appears with &nbsp characters on the end.
I have 2 inputs: they both have a width: 100% , and the second
I have some dynamically created inputs which are not server-side controls. I want to
I have code to create another row (div with inputs) on a button click.
I have a form on a page where the user has inputs to edit
I have a form in which people will be entering dollar values. Possible inputs:

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.