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

The Archive Base Latest Questions

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

so here is my problem i am getting data with getJSON and i made

  • 0

so here is my problem

i am getting data with getJSON and i made a option list, that is list of regions, and that is fine, now i need a functionality where clicking on list item i get another dropdown menu with list of towns for that region

so my code goes:

var encodedurl=escape("http:path");
$.getJSON("proxy3.php?url="+ encodedurl,

function(data) 
{   
$.each(data, function(i, item){
$("#grad_search").append('<option>' +item.city + "</option>");
});

so i need send variable from json in line var encodedurl=escape("http:path"); so when i click on list item i send data to another select option

var encodeurl_area=escape("http://some_path" + VARIABLE + "more_path");
$.getJSON("proxy3.php?url="+ encodeurl_area,
function(data)
{
$.each(data, function(i, item){
                            $("#kvart_search").append('<option>' + item.city_area + '</option>');
});     
}); 

so whole my problem is how to get VARIABLE in link above, i need get VARIABLE from my first function

  • 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-29T04:20:15+00:00Added an answer on May 29, 2026 at 4:20 am

    There are few things you should take care in your code.

    1. Before you start appending new cities(option) you should clear the list.
    2. Same applies to town list also
    3. When you populate the option, you should have a value for each option. This value can be used to pass for the next list to populate.

    Change your code like this.

    var encodedurl=escape("http:path");
    $.getJSON("proxy3.php?url="+ encodedurl,
    
    function(data) 
    {   
       //Look here I am using empty method to clear the existing list  
       $("#grad_search").empty()
       $.each(data, function(i, item){
          $("#grad_search").append('<option value="' 
                           + item.cityId + '">' +item.city + "</option>");
       });
    }
    
    //Handle the change event and pass the selected value to get city areas(towns)
    $("#grad_search").change(function(){
       var encodeurl_area=escape("http://some_path" + $(this).val() + "more_path");
       $.getJSON("proxy3.php?url="+ encodeurl_area, function(data)
         {
            //Look here I am using empty method to clear the existing list  
            $("#kvart_search").empty()
            $.each(data, function(i, item){
                $("#kvart_search").append('<option value="' 
                           + item.cityAreaId + '">' + item.city_area + '</option>');
            });     
       }); 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the problem. I have a stored procedure that transforms normalized data into
I'm getting crazy with a small problem here, I keep getting an error and
Here's the problem: In C# I'm getting information from a legacy ACCESS database. .NET
After getting a helpful answer here , I have run into yet another problem:
What is the problem here? (Besides having redundant code). $.getJSON works as expected. However
I've got a problem here with an MSI deployment that I'm working on (using
I have problem getting the dropdown menu to work using Twitter's Bootstrap. Here's my
I’m having a problem getting the data from my database which I created to
I have a problem getting my change(s) to data object retrieved using NHibernate to
Writing an iPhone app, and I'm getting my data from a REST API 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.