Select dependendes in php

0

I'm entering information into a form and I need my selects to be dependent. In this case, I have two selects, containing state information and from the selected state, the city information will appear in the other select. How to make?

<div id="info-geo">                  

<form name="novosDados" action="conexao.php" method="POST"> 

    <legend class="titulo" >Adicionar novo registro </legend> <br><br>

    <div class="w3-row-padding">

        <div class="w3-half">
          <label for="name">Estado</label>
          <select class="w3-select" name="estado">
            <option value="" disabled selected>Escolha um estado</option>
            <option value="BR">MG</option>
            <option value="EDE">SP</option>
            <option value="EVR">RJ</option>
          </select>                            
        </div>

        <div class="w3-half">
            <label for="name">Cidade</label>
            <select class="w3-select" name="cidade">

            <option value="" disabled selected>Escolha uma cidade</option>                                       
            <?php 
            if ($estado == 'MG'){ ?>
                <option value="BH">Belo Horizonte</option>
                <option value="Ipatinga">Ipatinga</option>
            <?php
            }
            ?>


            </select>                              
        </div>
        ....
        ....
        ....
        ....
</form>

How to get this value $ state, from my first select?

    
asked by anonymous 07.03.2018 / 18:42

0 answers