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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:15:27+00:00 2026-05-20T11:15:27+00:00

I am having a form written in php. In this form there is field

  • 0

I am having a form written in php. In this form there is field named ‘State’ and the Options of this field are the names of the states.There is another field named ‘District’ whose Options are the names of the District. The Options of the these two fields are being fetched from the database. There are about 28 states and there are about 12 Districts for each state. Now what is want is that when someone selects the state, then all the Districts corresponding to that state automatically appear in the District field.

  • 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-20T11:15:27+00:00Added an answer on May 20, 2026 at 11:15 am

    you could use an ajax call

    on the select put onchange="changedist(this.value)"

    and use the script function

    function changedist(str)
    {
    if (str=="")
      {
      document.getElementById("dist").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("dist").innerHTML=xmlhttp.responseText;
        }
    
    
      }
    
    xmlhttp.open("GET","./dist.php?q="+str,true);
    xmlhttp.send();
    }
    

    and call this values in your page
    <div id="dist"> here will returns the distrctis of the file dist.php</div>

    and dist.php

    $q = $_GET[q];
    $sql= "select * from dist where state = $q";
    
    
    $query ....
    
    
    echo ' <select name=dist>';
    while ($result = mysql_fetch_array($query))
    
    {
    echo " <option value=$result[key]>$result[dist]</option>";
    
    }
    

    so this will returns to your form page on the state change

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

Sidebar

Related Questions

There is a string having a dot form like this : 1.1.3 I want
Having just written the title for this question I am aware of how dodgy
There is another question on stackoverflow with this title. This is the link to
I've written about this a few times, but am still having difficulty seeing how
I'm having a problem using a CSV file uploaded via a PHP form. Here
I'm having issues getting a php form to write to a file hosted with
i am having an form for uploading an excel file like <form enctype=multipart/form-data action=http://localhost/joomla/Joomla_1.5.7/index.php?option=com_jumi&fileid=7
Having construction in a form: struct Node { Node():left_(nullptr), right_(nullptr) { } int id_;
Having a popup menu attached to several components on a form (buttons, but also
Having created dropdown lists using ViewBag which is working in an edit form. How

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.