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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:09:27+00:00 2026-05-29T11:09:27+00:00

I’ve included javascript and HTML code, not full, but hopefully enough to give you

  • 0

I’ve included javascript and HTML code, not full, but hopefully enough to give you idea. At the moment It works this way:
– If I click on input (id=zipcode), it shows prompt box in which you enter ZIP code.

I would like to know, if i can get rid of this prompt box and just do it this way:
– If I click on input (id=zipcode), it just shows a “bubble” with text above the input field “enter a zip code and the city/state will be pre-filled” … basicaly I would like to make autocompleter on the ZIP input field…

Javascript code:

function prefillLocale(zip)
{
    var doc, City, State, ZipCode;

    ZipCode = document.getElementById("ZipCode");
    City = document.getElementById("City");
    State = document.getElementById("State");
    doc = ajax(doc);

    // Load the result from the response page
    // ** As far a I know firefox will only load a document on the SAME domain!!    
    if (doc)
    {
        var cmd = "../ajaxLocales.php?type=zip2cs&z=" + zip;

        doc.open("GET", cmd, false);
        doc.send(null);

        var arraylist=doc.responseText.split("|");

        City.value = arraylist[0];
        State.value = arraylist[1];
            ZipCode.value = zip;
        }
        return true;
    }

        var bDoneOnce = new Array();

        function getZip1(ID

)
    {
        if(bDoneOnce[ID] != undefined)  return;
        bDoneOnce[ID] = 1;

        var zip=prompt("Enter a zip code and the city/state will be pre-filled.","");
        if (zip!=null && zip!="")
        {
            prefillLocale1(zip,ID);
        }
        document.getElementById("City"+ID).focus();
    }

HTML code:

<div style="margin-left: 182px;">
<input type="text" onfocus="getZip1(50);" class="ac_input" value="Texas" id="State50" size="15" name="State">
<input type="text" onfocus="getZip1(50);" class="ac_input" value="75038" id="ZipCode50" size="5" maxlength="5" name="ZipCode">
</div>
  • 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-29T11:09:28+00:00Added an answer on May 29, 2026 at 11:09 am

    UPDATE

     - Was going to update this with personally written code, but then a co-worker 
       filled me on the following link 
    

    http://www.jensbits.com/2010/05/29/using-jquery-autocomplete-to-populate-another-autocomplete-asp-net-coldfusion-and-php-examples/

    And another great example (with ASP and Coldusion examples!!!)

    http://www.jensbits.com/2010/05/29/using-jquery-autocomplete-to-populate-another-autocomplete-asp-net-coldfusion-and-php-examples/

     - Looks like it would probably be better you start there as my explanation 
       would probably go too deep into the depth of getting everything setup.  
     - Give that sight a try, and if you have anymore questions, 
       feel free to hit me back up, though I'm quite sure if you go through his 
       walk-through, with a little more jQuery understanding, you'll be able to do 
       exactly what you want to do when you're done.
    

    Don’t forget to get jQueryUI so you can make use of this awesome jQuery add-in

    I am unclear as to your full intentions, especially since your code makes very little sense. However, I was able to interpret some parts and point out some things “general practices” for use with jQuery. Below is the best interpretation of your code with jQuery specific changes, the biggest one being, you no longer need ocument.getElementById as jQuery has replaced this with a simple $(insertElementIdOrClassNameOrCssSelectorHere). You will find jQuery makes almost everything in javascript…Easier!

    Your previous code: (gimmie feed back and I will attempt to help you fully fix the problem)

    function prefillLocale(zip) {
        var doc = ajax(doc),    // ?!?
            City = $("City"),
            State = $("State"),
            ZipCode = $("ZipCode");
    
        // Load the result from the response page
        // ** As far a I know firefox will only load a document on the SAME domain!!
        if (doc) {
            var cmd = "../ajaxLocales.php?type=zip2cs&z=" + zip;
    
            doc.open("GET", cmd, false);
            doc.send(null);
    
            var arraylist=doc.responseText.split("|");
    
            City.value = arraylist[0];
            State.value = arraylist[1];
            ZipCode.value = zip;
            return true;
        }
    
        var bDoneOnce = new Array();
    
        function getZip1(ID) {
            if(bDoneOnce[ID] != undefined)  return;
            bDoneOnce[ID] = 1;
    
            var zip=prompt("Enter a zip code and the city/state will be pre-filled.","");
            if (zip!=null && zip!="") {
                prefillLocale1(zip,ID);
            }
            $("#City"+ID).focus();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.