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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:55:12+00:00 2026-05-28T06:55:12+00:00

Ok, so either I can’t search the web properly, or I can’t understand, the

  • 0

Ok, so either I can’t search the web properly, or I can’t understand, the point of my search results, but after several days of searching and trying to do it by my own, I still have no simple and understandable answer!

I have a flight search form with select boxes.
Select box results are populated via PHP from MySQL.

Example:

Forward flight:

Departure city – “London”

Destination city – All cities exept London

Flight date – All flight dates for flight London->Forward Destination
City

Backward flight:

Departure city – Again all cities exept London

Destination city – All cities exept Backward Departure City

Flight date – All flight dates for flight Backward Departure
City->Backward Destination City

I have no problem making this form using only PHP and form GET method, but, of course, I’d like to get rid of page reloading. Obvious solution – AJAX.

My approach:

  1. Use onChange event on select box for calling javascript function with attribute ‘this.value’
  2. javascript function sends XMLHttpRequest to the server (.php file) with GET method
  3. .php file contains functions with MySQL requests, that are called with simple “if ($_GET[‘value_sent_with_javascript_function’])”
  4. javascript function places php responce in a div – document.getElementById(“div_id”).innerHTML=xmlhttp.responseText;

This works fine for two fileds (first one is “parent”, the second one – “child” – is populated depending on “parent” box selected value). But if i want to use same method to populate third field (the one that is dependant on “child”), it’s just doesnt’ work. As I’m not the specialist in javascript, I just can’t figure this out.

I bet there is a simple solution!

  • 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-28T06:55:13+00:00Added an answer on May 28, 2026 at 6:55 am

    A simple example that should set you on your way:

    Main.php file

        <script type="text/javascript">
        function loadXMLDoc(step)
        {
            var showPage;
            var rrestultBox;
    
            if (step==1)
            {
                showPage = 'destination.php?select=' + document.getElementById('departure').value;
                resultBox = 'destinationBox';
            }
            if (step==2)
            {
                showPage = 'times.php?select=' + document.getElementById('destination').value;
                resultBox = 'timesBox';
            }
            var xmlhttp;
            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(resultBox).innerHTML=xmlhttp.responseText;
            }
        }
            xmlhttp.open("GET",showPage,true);
            xmlhttp.send();
        }
    </script>
    <form name="selectBoxes">
        <select name="departure" id="departure" onchange="loadXMLDoc(1);">
            <option value="sydney">Sydney</option>
            <option value="canberra">Canberra</option>
            <option value="Melbourne">Melbourne</option>
        </select>
    </form>
    <div id="destinationBox"></div>
    <div id="timesBox"></div>
    

    destination.php

    <form name="selectBoxes">
        <select name="destination" id="destination" onchange="loadXMLDoc(2);">
            <option value="sydney">Sydney</option>
            <option value="canberra">Canberra</option>
            <option value="Melbourne">Melbourne</option>
        </select>
    </form>
    

    times.php file

    <form name="selectBoxes">
    <select name="times" id="times"">
        <option value="">1pm</option>
        <option value="">2pm</option>
        <option value="">3pm</option>
    </select>
    

    watch it in action: here

    **updated, forgot to add ‘destination.php’

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

Sidebar

Related Questions

Im trying to add a constraint to a reservation table, the reservation can either
Possible Duplicate: Searching a log file Where I can either enter a binary file
I have a HQL query that can generate either an IList of results, or
We have got a setup where users can either use a web-based form or
The documentation implies that you can either have 3D rendering or framebuffer mode, and
I have a variable that can either contain a list of strings or a
Suppose I have a function which can either take an iterable/iterator or a non-iterable
I have a function whose input argument can either be an element or a
Given i have the IO function: // this can either be IO or some
I have a JSON string (external file) which has an element which can either

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.