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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:24:52+00:00 2026-05-29T05:24:52+00:00

<div data-role=page id=page> <div data-role=header> <h4> Page Refresh</h4> </div> <div data-role=content> <div data-role=fieldcontain data-theme=b>

  • 0
<div data-role="page" id="page">
    <div data-role="header">

    <h4> Page Refresh</h4>
    </div>

    <div data-role="content">       

          <div data-role="fieldcontain" data-theme="b">
            <ul data-role="listview" data-inset="true">

            <li data-role="list-divider"> List of Contractors </li>         
                <li> 
                    <label for="select-choice-1" class="select">Main Location</label>
                       <select name="main_location" id="select-choice-1">
                          <option value="NSW">NSW</option>
                          <option value="ACT">ACT</option>
                          <option value="VIC">VIC</option>
                          <option value="SA">SA</option>
                          <option value="QLD">QLD</option>
                          <option value="NT">NT</option>
                          <option value="WA">WA</option>
                          <option value="TAS">TAS</option>
                        </select>                     
              </li> <!-- Select Menus: Main Location-->  

                <li>  <h3> Company 1 in NSW  </h3>    </li>                     
                <li>  <h3> Company 2 in NSW  </h3>    </li>                     
                <li>  <h3> Company 3 in NSW  </h3>    </li>                     
                <li>  <h3> Company 4 in NSW  </h3>    </li>                                                         

          </div>       
    </div>
    <div data-role="footer">

    </div>
</div>

I have a drop down that has list of States, below it I’ve List of companies.

I was wondering if I can dynamically populate list of companies with out page refresh based on the value selected in Drop down.

In simple words, if the value selected NSW then the list of companies should only contain companies in NSW state.

I would appreciate if some one can explain me with an example.

  • 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-29T05:24:53+00:00Added an answer on May 29, 2026 at 5:24 am

    PHP code is read by the server and then output is converted to HTML.

    The only way to get PHP read again (after performing an action on the page) is to resubmit the page or be directed to a new one.

    You can use JavaScript to do things on the client-side, but again, PHP code is read at the beginning only.

    Here’s an example of something you could do using JS:

    <form name="vehicle">
        Car Make: 
        <select name="carbrand" onChange="updatecartype(this.selectedIndex)" >
        <option selected>Select A Car Brand</option>
        <option value="ford">Ford</option>
        <option value="mazda">Mazda</option>
        <option value="kia">Kia</option>
        </select>
    
        Car Model: 
        <select name="cartype" >
        <option value="NONE" selected>-------------------</option>
        </select>
    </form>
    
    <script type="text/javascript">
    
        var carbrandlist=document.vehicle.carbrand
        var cartypelist=document.vehicle.cartype
    
        var cartype=new Array()
        cartype[0]=""
        cartype[1]=["Focus|focus", "F-150|f150", "Taurus|taurus"]
        cartype[2]=["Protege|protege", "Tribute|tribute", "RX-8|rx8", "CX-9|cx9"]
        cartype[3]=["Rio|rio", "Sedona|sedona", "Optima|optima", "Soul|soul", "Sorento|sorento"]
    
        function updatecartype(selectedcar){
            cartypelist.options.length=0
            if (selectedcar>0){
                for (i=0; i<cartype[selectedcar].length; i++)
                cartypelist.options[cartypelist.options.length]=new Option(cartype[selectedcar][i].split("|")[0], cartype[selectedcar][i].split("|")[1])
            }
        }
    
    </script>
    

    Here’s a straight-forward re-submit/2 page approach using only PHP, as requested.

    //step1.php
    //================
    
    <form method='post' action='step2.php'>
    
    Choose State <br>
    <select name='state'>
    <option value='MI'>Michigan</option>
    <option value='IL'>Illinois</option>
    </select>
    
    <input type='submit' value='Select State'>
    
    </form>
    
    
    
    //step2.php
    //================
    
    <form method='post' action='step3.php'>
    
    Choose Company <br>
    <select name='company'>
    
    <?php
    $state_choice = $_POST['state'];
    
    if ($state_choice == 'MI') {
    
        echo "<option value='ABC'>Company ABC</option>";
        echo "<option value='DEF'>Company DEF</option>";
    
    }
    if ($state_choice == 'IL') {
    
        echo "<option value='UVW'>Company UVW</option>";
        echo "<option value='XYZ'>Company XYZ</option>";
    
    }
    ?>
    
    </select>
    
    <input type='submit' value='Select Company'>
    
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<div data-role=content> <ul data-role=listview data-theme=a data-dividertheme=b> <li data-role=list-divider >Transition Effects</li> <li><a href=#second>Slide</a></li> <li><a href=TestPage1.htm![enter
This is my code: <div data-role=content data-theme=b> <div data-scroll=y> <ul> <li data-role=button data-icon=arrow-r onclick=redirectPage(1);>All
Short: Do you put the data-role portions (header|content|footer) in your layout/master page or in
I have this: <div data-role=header > <div data-role=controlgroup data-type=horizontal > <div id=b1 data-role=button >b1</div>
I have the following code: @{ ViewBag.Title = Index; } <h2> Index</h2> <div data-role=page>
Tried... <div data-role=page data-cache=30> <div data-role=page data-cache=never> <div data-role=page data-cache=false> <div data-role=page cache=false> Nothing
So I have a Radio button group, like so: <div data-role=fieldcontain> <fieldset data-role=controlgroup> <legend>Choose
If I have HTML content in a variable like so: var data = <div
I have the following jquery mobile code: <div data-role=collapsible> <h3>I like to read a
In knockoutjs 1.2.1 I could do: <div data-bind=template: {name: 'Bar', foreach: persons, templateOptions:{fooMode: true}

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.