$ _POST of dynamic variables

0

Hello, I'm having trouble retrieving for $_POST after submitting the form values for dynamic fields added with jQuery .

I'm getting the selects of the same line popular and everything is working, the big problem is: When I try to get all the information by POST after submitting the form, only the first line information is displayed.

HTML Code

      <form action = "abrir-inscricoes.php" method = "post">
                    <tr><th>Nível</th>
                        <th>Programa</th>
                        <th>Semestre</th>
                        <th>Ano</th>
                        <th>Data Inicial</th>
                        <th>Data Final</th>
                    </tr>
                    <tbody style="background-color: #7AA3CC;">                        
                        <tr style="background-color: #7AA3CC;" class="linha">
                            <td>
                                <select class="select_nivel" name="niveis[]">
                                    <option value="" disabled selected style="display:none">Nivel</option>
                                    <?php
                                        $qtdreg = sizeof($niveis);
                                        for ($i=0; $i<$qtdreg; $i++) {
                                            echo "<option value=\"".$niveis[$i]['id']."\">".$niveis[$i]['descricao']."</option>";
                                        }
                                    ?>
                                </select>
                            </td>

                            <td><select class="select_programa" name="programas[]">
                                    <option value="" disabled selected style="display:none">Programa</option>
                                </select>
                            </td>

                            <td>
                                <select class="select_semestre" name="semestres[]">
                                    <option value="" style="display:none" disabled selected>Semestre</option>
                                    <option value="1">Primeiro</option>
                                    <option value="2">Segundo</option>
                                </select>
                            </td>
                            <td>
                                <select class="select_ano" name="anos[]">
                                    <option value="" style="display:none" disabled selected>Ano</option>
                                    <option value="<?= $ano ?>" ><?= $ano ?></option>
                                    <option value="<?= $ano + 1 ?>" ><?= $ano + 1 ?></option>
                                </select>
                            </td>
                            <td><input type="text" class="dt_inicial" name="dt_iniciais[]" style="width: 92px;" value=""></td>
                            <td><input type="text" class="dt_final" name="dt_finais[]" style="width: 92px" value=""></td>
                        </tr>

                        <tr class="adicionar"><td><a style="cursor:pointer" id="adicionar">+ Alterar outra inscrição</a></td>
                            <td><a style="cursor:pointer" id="alterar_tudo">+ Alterar todas as inscrições</a></td></tr>

                        <tr style="background-color: #7AA3CC;">
                            <td><input type="submit" class="botao-abrir-inscricao" value="Enviar"></td>
                        </tr>
                        <tr style="background-color: #99ddff;">                   
                        </tr>
                    </tbody>
                </form>

Code jQuery to add fields:

$('#informacoes').on('click',"#adicionar",  function(){    
            var linha = $('.linha').eq(0).clone();  
            linha.find('select').val('');

            $('.adicionar').before(linha);
});    

Trying to display the $ _POST values:

if (isset($_POST["programas"]))      
            var_dump($_POST);

Thank you in advance!

HTML GENERATED AFTER ADDING 1 OPTION

<tbody style="background-color: #7AA3CC;">                        
                        <tr style="background-color: #7AA3CC;" class="linha">
                            <td>
                                <select class="select_nivel" name="niveis[]">
                                    <option value="" disabled="" selected="" style="display:none">Nivel</option>
                                    <option value="1">Mestrado</option><option value="2">Doutorado</option><option value="3">Especial</option>                                    </select>
                            </td>

                            <td><select class="select_programa" name="programas[]">
                                    <option value="" disabled="" selected="" style="display:none">Programa</option>
                                </select>
                            </td>

                            <td>
                                <select class="select_semestre" name="semestres[]">
                                    <option value="" style="display:none" disabled="" selected="">Semestre</option>
                                    <option value="1">Primeiro</option>
                                    <option value="2">Segundo</option>
                                </select>
                            </td>
                            <td>
                                <select class="select_ano" name="anos[]">
                                    <option value="" style="display:none" disabled="" selected="">Ano</option>
                                    <option value="2016">2016</option>
                                    <option value="2017">2017</option>
                                </select>
                            </td>
                            <td><input type="text" class="dt_inicial" name="dt_iniciais[]" style="width: 92px;" value=""></td>
                            <td><input type="text" class="dt_final" name="dt_finais[]" style="width: 92px" value=""></td>
                        </tr>

                        <tr style="background-color: #7AA3CC;" class="linha">
                            <td>
                                <select class="select_nivel" name="niveis[]">
                                    <option value="" disabled="" selected="" style="display:none">Nivel</option>
                                    <option value="1">Mestrado</option><option value="2">Doutorado</option><option value="3">Especial</option>                                    </select>
                            </td>

                            <td><select class="select_programa" name="programas[]">
                                    <option value="" disabled="" selected="" style="display:none">Programa</option>
                                </select>
                            </td>

                            <td>
                                <select class="select_semestre" name="semestres[]">
                                    <option value="" style="display:none" disabled="" selected="">Semestre</option>
                                    <option value="1">Primeiro</option>
                                    <option value="2">Segundo</option>
                                </select>
                            </td>
                            <td>
                                <select class="select_ano" name="anos[]">
                                    <option value="" style="display:none" disabled="" selected="">Ano</option>
                                    <option value="2016">2016</option>
                                    <option value="2017">2017</option>
                                </select>
                            </td>
                            <td><input type="text" class="dt_inicial" name="dt_iniciais[]" style="width: 92px;" value=""></td>
                            <td><input type="text" class="dt_final" name="dt_finais[]" style="width: 92px" value=""></td>
                        </tr><tr style="background-color: #7AA3CC;" class="linha">
                            <td>
                                <select class="select_nivel" name="niveis[]">
                                    <option value="" disabled="" selected="" style="display:none">Nivel</option>
                                    <option value="1">Mestrado</option><option value="2">Doutorado</option><option value="3">Especial</option>                                    </select>
                            </td>

                            <td><select class="select_programa" name="programas[]">
                                    <option value="" disabled="" selected="" style="display:none">Programa</option>
                                </select>
                            </td>

                            <td>
                                <select class="select_semestre" name="semestres[]">
                                    <option value="" style="display:none" disabled="" selected="">Semestre</option>
                                    <option value="1">Primeiro</option>
                                    <option value="2">Segundo</option>
                                </select>
                            </td>
                            <td>
                                <select class="select_ano" name="anos[]">
                                    <option value="" style="display:none" disabled="" selected="">Ano</option>
                                    <option value="2016">2016</option>
                                    <option value="2017">2017</option>
                                </select>
                            </td>
                            <td><input type="text" class="dt_inicial" name="dt_iniciais[]" style="width: 92px;" value=""></td>
                            <td><input type="text" class="dt_final" name="dt_finais[]" style="width: 92px" value=""></td>
                        </tr><tr class="adicionar"><td><a style="cursor:pointer" id="adicionar">+ Alterar outra inscrição</a></td>
                            <td><a style="cursor:pointer" id="alterar_tudo">+ Alterar todas as inscrições</a></td></tr>

                        <tr style="background-color: #7AA3CC;">
                            <td><input type="submit" class="botao-abrir-inscricao" value="Enviar"></td>
                        </tr>
                        <tr style="background-color: #99ddff;">                   
                        </tr>
                    </tbody>
    
asked by anonymous 29.06.2016 / 19:43

0 answers