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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:01:16+00:00 2026-06-17T03:01:16+00:00

EDITED: SQL $valuefromjs = $_REQUEST[‘var’]; $result6 = SELECT DISTINCT $valuefromjs FROM persons ORDER BY

  • 0

EDITED:

SQL

$valuefromjs = $_REQUEST['var'];
$result6 = "SELECT DISTINCT $valuefromjs FROM persons ORDER BY $valuefromjs ASC";
$result7 = mysql_query($result6);
$num = mysql_num_rows($result7);  

$dataRanges[0] = array('dataRanges');       
        for ($i=1; $i<($num+1); $i++)
        {
        $dataRanges[$i] = array( (int) mysql_result($result7, $i-1) );
        }

echo json_encode($dataRanges);

HTML

<select id="combo2" class="combo" data-index="2"></select>

jQuery

$('#1combo').on('change', function () {
var jsonVar = $.ajax({
url : "visits/comboquery.php?var="+$(this).val(), 
dataType: "json",
async: false,
success: function(response) {
}
}).responseText;
for (var i=1; i<objVar.length;i++)
    {
    $('#combo2').html("<option value="+objVar[i]+">"+objVar[i]+"</option>");
    }
});

QUESTION:

I have an array with query results. Now i need that results be the combo2 options, what is wrong?

  • 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-17T03:01:17+00:00Added an answer on June 17, 2026 at 3:01 am

    To my understanding the choice from combo1 will define which query to run for building combo2.

    The issue: your PHP for building the combo2 is parsed at the server side i.e. the PHP code is always finished executing by the time the page reaches the user’s browser and your javascript begins to execute.

    If you have a finite set of possible queries that can generate the seconds combo (which should be the case since combo1 has a finite number of options), you can create all of them, each with a different id, and maintain them hidden (css “display: none”).

    <select id="firstCombo2" class="combo2">
        ...
    </select>
    <select id="secondCombo2" class="combo2">
        ...
    </select>
    

    etc.

    Now, when the user makes a selection from combo1, you can decide which one of the hidden combo2’s you are going to display (css “display: block”).

    $('select#combo1).on("change", function(){
        $('select.combo2').css('display','none'); //hide all combo2's
        if($(this).val()=='Opt1'){
                $('select#firstCombo2').css('display','block');
        }else if($(this).val()=='Opt2'){
                $('select#secondCombo2').css('display','block');
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

below is my sql query SELECT individuals.* FROM ( select children.* FROM checkins, children
Have following String built SQL query: StringBuilder querySelect = new StringBuilder(select * from messages
I can display my data in my textbox, dropdownlist after retrieve data from sql
I have a SQL Query as below: SELECT urban_appr, urban_in, rural_appr, rural_in, ground_appr, ground_in
How to find distinct of date in sql 2000? For example :i have a
I recently had to switch from using Microsofts SQL server to using MySQL. The
[EDITED] I am connecting to SQL Server 2005. i have configured the certificate on
I have edited this from my real code, so that it is a little
So I am trying to get the result as count from a sql query
How to enable logging of all SQL executed by PostgreSQL 8.3? Edited (more info)

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.