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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:51:51+00:00 2026-06-08T17:51:51+00:00

I have the following simple form from which a user can select a state

  • 0

I have the following simple form from which a user can select a state to view information on:

<form style="position:absolute; top:65px; left:650px">
    Select State to View:
    <select id="myList" onchange="load_state_data(); xml = getStateInfo();">
      <option selected="selected"></option>
        <?php
            foreach($stateNames as $state){
                echo('<option>'.$state.'</option>');
            }
        ?>
    </select>
</form>

My javascript is as follows:

function load_state_data() {
    var state_name = $("#myList option:selected").val();
    $.ajax({
        type: 'post',
        url: 'state_data.php',
        dataType: "xml",
        data: {
            state_name: $("#myList option:selected").val()
        },
        success: function (data) {
            //clear out previous values
            for (j = 0; j < 5; j++) {
                $('#top_name_' + j).html("");
                $('#top_score_' + j).html("");
            }

            $(data).find('TOP').each(function (index) {
                $('#top_name_' + index).html($(this).find('COMPANY_NAME').text());
                $('#top_score_' + index).html($(this).find('Q_SCORE').text());
            });

            //initialize my temp arrays for reverse ordering the results
            var botName = new Array();
            var botScore = new Array()

            //clear out previous values
            for (j = 0; j < 5; j++) {
                $('#bot_name_' + j).html("");
                $('#bot_score_' + j).html("");
            }

            $(data).find('BOTTOM').each(function (index) {
                //$('#bot_name_'+index).html($(this).find('COMPANY_NAME').text());
                //$('#bot_score_'+index).html($(this).find('Q_SCORE').text());
                botName[index] = $(this).find("COMPANY_NAME").text();
                botScore[index] = $(this).find("Q_SCORE").text();
                j = index;
            });
            var newOrderName = botName.reverse();
            var newOrderScore = botScore.reverse();
            for (i = 0; i < newOrderName.length; i++) {
                $('#bot_name_' + i).html(newOrderName[i]);
                $('#bot_score_' + i).html(newOrderScore[i]);
            }

            //clear the variables from memory
            delete botName;
            delete botScore;
            delete newOrderName;
            delete newOrderScore;


            //cycle through results and save my locations to an array of the map markers
            var inst_info = new Array();
            $(data).find('INST_MARKER').each(function (index) {
                inst_info[index] = [parseFloat($(this).find('LAT').text()),
                parseFloat($(this).find('LONG').text()),
                $(this).find('COMPANY_NAME').text(), $(this).find('Q_SCORE').text()];
            });

            $(data).find('INST_COUNT').each(function () {
                $('#num_total').html($(this).find('NUM_TOTAL').text());
                $('#num_null').html($(this).find('NUM_NULL').text());
            });
            return (inst_info);
        },
        error: function (data) {
            alert('There was an error. Please try again shortly.');
        }
    });
};

I need to access the inst_info generated in this script back on the page it is called from (see form above). Is this possible, and, if so, how? I have tried using inst_info = function load_state_data, but that doesn’t work.

  • 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-08T17:51:53+00:00Added an answer on June 8, 2026 at 5:51 pm

    I need to access the inst_info generated in this script back on the page it is called from (see form above). Is this possible, and, if so, how?

    No. The inst_info is created in the callback function for the success event of your asynchronous request. From there it is available, and you will be able to call a function that sets the state information.

    All this happens in the future, after your load_state_data function returns. Yet, you might return a Promise for the data, on which other callback functions can be registered to be executed as soon as the data is available.


        //clear the variables from memory
        delete ...
    

    This code does not work, it is a misuse of the delete operator. You don’t need to do this anyway, JavaScript is a garbage-collected language.

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

Sidebar

Related Questions

I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which
I have following rather simple query select count(*) from tbl t1, tbl t2 For
Lets say that you have a following simple application: <form action=helloServlet method=post> Give name:<input
I have a simple html form that looks like the following <form action=search.php method=get>
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
I have a simple PHP script with a form that has two select fields,
I have a form which has two inputs. The first input allows a user
I have the following multiselect control in a Ext JS form which looks like
I have something pretty simple which I've thrown together. I have a little form
I have the following $_FILES array past through for processing from a support form

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.