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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:25:27+00:00 2026-05-19T13:25:27+00:00

I have a php file Criteria to display a bunch of html multi select

  • 0

I have a php file “Criteria” to display a bunch of html multi select dropdowns that can be used to create criteria for a query.

I have a php file “Results” which builds an SQL statement according to the selected options from various dropdowns, executes the query, and then displays the results of that query.

I would like to skip having to reload & echo all the html for each select dropdown, as they each contain hundreds of options. Ajax was my solution for this.

For each dropdown, an onchange event calls my javascript, which executes an Ajax call to my “Results” page. This “Results” page would then get the value of each select dropdown using $_POST[‘htmlSelectDropdownID’].

The problem, now that I have implemented Ajax, is that the selected value from the select dropdowns is not coming across to my Results file… and I can only assume this is because the HTML never reloaded…

Does anybody have a suggestion of how to resolve this issue?

Thanks,

———————— code ————————–

My Javascript / Ajax

 function AjaxPostback(){
/*if (str=="")
{
    document.getElementById("divTest").innerHTML="";
    return;
} */
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4)// && xmlhttp.status==200)
    {
        document.getElementById("divResults").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","Results.php", true); //?q="+str,true);
xmlhttp.send();}

Just 1 of the dropdown on my page

Group By <select id="selGroupBy" name="selGroupBy" onchange="AjaxPostback()">
            <option value='Department' <?php if ($_POST['selGroupBy'] == 'Department') echo 'selected="selected"'; ?>>Department</option>
            <option value='Store' <?php if ($_POST['selGroupBy'] == 'Store') echo 'selected="selected"'; ?>>Store</option>
            <option value='Date' <?php if ($_POST['selGroupBy'] == 'Date') echo 'selected="selected"'; ?>>Date</option>
            <option value='Size' <?php if ($_POST['selGroupBy'] == 'Size') echo 'selected="selected"'; ?>>Size</option>
        </select>

—
The html that builds the Criteria (dropdown html) and the div (divResults) who’s innerHTML is filled with the javascript

<div>
            <?php include ("Criteria.php"); ?>

            <div class="divResults" id="divResults">
                &nbsp;
            </div>
        </div>

When called, my Results.php file simply checks to document for things like..
if (isset($_POST[‘selDepartment’]) && ($_POST[‘selDepartment’] == “320 Socks”) {
$sqlSelect .= $_POST[‘selDepartment’];
}

I have also tried using $_GET instead of $_POST to retrieve the value, same result.. =\

  • 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-19T13:25:27+00:00Added an answer on May 19, 2026 at 1:25 pm

    It seems that you never send any param to your Results page. Try to add this:

    xmlhttp.open("GET","Results.php?selGroupBy="+document.getElementById("selGroupBy").value, true); //?q="+str,true);
    

    And get it on your php page with:

    $val = $_GET['selGroupBy'];
    

    Well, I maybe not understand your prob.

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

Sidebar

Related Questions

I have a php file that outputs 0 or 1. How can I use
I have a PHP file that gets HTML from Memcached and serves it to
I have a PHP file that contains a lot of if and else statements
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have a php file that contains a form (which contains 2 input boxes
I have a php file that has some local and global variables (e.g. $foo)
I have a php file that is only accessed through ajax. The ajax call
I have a PHP file with PHP Variables inside. Example: Hi <?=$username?>, Can you
I have a php file that needs to be called directly. It renders PDF
I have php file with a class in it that needs to read a

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.