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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:06:56+00:00 2026-05-27T01:06:56+00:00

Possible Duplicate: jQuery variable claiming it's undefined when it has been defined The problem

  • 0

Possible Duplicate:
jQuery variable claiming it's undefined when it has been defined

The problem is that when opening it in firefox and typing a value for input 1 and selecting it, firebug says that the variable phone isn’t defined. I tried defining the variables at the start but it still ceased to work.

This is the jQuery:

$(document).ready(function() {

var phone;  //fix scoping
var phoneid;
var firmware;
var firmwareid;

$("#input1").autocompleteArray(["iPhone 2G","iPhone 3G","iPhone 3GS","iPhone 4","iPhone 4s"],
{   minChars:1,
    matchSubset:1,
    onItemSelect:selectPhone,
    onFindValue:findPhone,
    autoFill:true,
    maxItemsToShow:10,
    selectFirst:true,
});

$("#input2").autocompleteArray(["1.1","1.2","1.3","1.4","1.5"],
{   minChars:1,
    matchSubset:1,
    onItemSelect:selectFirmware,
    onFindValue:findFirmware,
    autoFill:true,
    maxItemsToShow:10,
    selectFirst:true,
    });



function findPhone(li) {
    if( li == null ) return alert("No match!");
    phone = li.selectPhone;
    phoneid = phone.replace("iPhone ","iphone").toLowerCase();
};

function findFirmware(li) {
    if( li == null ) return alert("No match!");
    firmware = li.selectFirmware;
    firmwareid = phone.replace(".","");
    $(".info").hide
    $(phoneid+firmware).show
};

function selectPhone(li) {
    findPhone(li);
}

function selectFirmware(li) {
    findFirmware(li);
}
    });

And this is the HTML:

<div id="formcontainer">
        <input id="input1"/>
        <input id="input2"/>
</div>
<div id="iphone2g11" class="info" style="display:none">iPhone 2G</div>
<div id="iphone2g12" class="info" style="display:none">iPhone 3G</div>
<div id="iphone2g13" class="info" style="display:none">iPhone 3GS</div>
<div id="iphone2g14" class="info" style="display:none">iPhone 4</div>
<div id="iphone2g15" class="info" style="display:none">iPhone 4S</div>

I’m using this plugin for autocomplete http://www.pengoworks.com/workshop/jquery/autocomplete.htm

  • 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-27T01:06:56+00:00Added an answer on May 27, 2026 at 1:06 am

    The problem is in your findFirmware() function, change it to

    function findFirmware(li) {
        if( li == null ) return alert("No match!");
        firmware = li.selectFirmware;
        firmwareid = phone.replace(".","");
        $(".info").hide();
        $('#' + phoneid + firmwareid).show(); // This line was messed up
    };
    

    There two problems with this line $(phoneid+firmware).show, well four if you count the missing parenthesis and semicolon but…

    1. The div your trying to show has an ID, you don’t have # in your selector to select the element by ID
    2. firmware contains the unparsed string with the period so phoneid + firmware becomes iphone2g1.2 when your div ID is iphone2g12 thus you needed to use firmwareid in which you parsed it out of.

    Fiddle Demo: http://jsfiddle.net/AaNWM/

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

Sidebar

Related Questions

Possible Duplicate: Change single variable value in querystring I'm retrieving the current URL: http://example.com/?s=original&fq=category
Possible Duplicate: jQuery delay between animations I have created two functions: One that animates
Possible Duplicate: jQuery Ajax always returns “undefined”? I'm trying to come up with a
Possible Duplicate: In jquery: Use attr(“class”) value as a selector? I have fields with
Possible Duplicate: Submit a form using jQuery $('#form') Supposed the jQuery Object of the
Possible Duplicate: Client Id for Property (ASP.Net MVC) In my View I'm using jquery
Possible Duplicate: javascript: pause setTimeout(); Im using jQuery and working on a notification system
Possible Duplicate: What Ruby IDE do you prefer? I've generally been doing stuff on
Possible Duplicates: Why would a javascript variable start with a dollar sign? JQuery :
Possible Duplicate: jQuery: text() vs html()? What's the difference between text and html() in

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.