Make a while run from the click of a button

Asked

Viewed 50 times

0

I have a form that must be filled out automatically. But this fulfillment depends on a user’s choice, so it should be executed after the choice, I believe a button would be ideal.

To illustrate the following: I have several car assemblers (Volkswagen, Ford, Peugeot). The user will choose which assembler you want in a drop down field. As you choose, a form must be filled out "automatically" with all the cars of this automaker (registered in the BD). For example: Chose Volkswagen in the Meno drop down, then the form must be filled with the vehicles Parati, Gol, Santana...

I did a "while" bringing all the medications from a certain group of medications. But it does not bring any results because it runs when the page opens. I need to create a "button" or a way to be executed only after the user choose the type of medicines group, so yes my while running and fill out the entire form.

Follow the While:

        while (($exibe = oci_fetch_array($parsed_medicamento_s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
                                                $DS_MATERIAL                = $exibe ['DS_MATERIAL'];
                                                $DS_VIA_APLICACAO           = $exibe ['DS_VIA_APLICACAO'];
                                                $QT_DOSE                    = $exibe ['QT_DOSE'];
                                                $DS_INTERVALO               = $exibe ['DS_INTERVALO'];
                                                $CD_UNIDADE_MEDIDA          = $exibe ['CD_UNIDADE_MEDIDA'];
                                                $DS_DIAS_APLICACAO          = $exibe ['DS_DIAS_APLICACAO'];
                                                $DS_CICLOS_APLICACAO        = $exibe ['DS_CICLOS_APLICACAO'];
                                                $DILUICAO_RECONSTITUINTE    = $exibe ['DILUICAO_RECONSTITUINTE'];
                                                $DS_RECONSTITUINTE          = $exibe ['DS_RECONSTITUINTE'];
                                                $UNID_MED_RECONSTITUINTE    = $exibe ['UNID_MED_RECONSTITUINTE'];
                                                $DS_DILUINTE                = $exibe ['DS_DILUINTE'];
                                                $QT_DOSE_DILUENTE           = $exibe ['QT_DOSE_DILUENTE'];
                                                $CD_UNIDADE_MEDIDA_DILUENTE = $exibe ['CD_UNIDADE_MEDIDA_DILUENTE'];

    echo '<div class="tbline"><div class="tbcel1 excluir"><a href="?exclui=ok&id='.$idsession.'&nr_sequencia='.$NR_SEQUENCIA.'"><font color="#FFFFFF">excluir</font></a></div><div class="tbcel3">'.$DS_MATERIAL.'</div><div class="tbcel2">'.$DS_VIA_APLICACAO.'</div><div class="tbcel2">'.$QT_DOSE.'</div><div class="tbcel2">'.$DS_UNIDADE_MEDIDA.'</div><div class="tbcel3">'.$DS_DIAS_APLICACAO.'</div><div class="tbcel3">'.$DS_CICLOS_APLICACAO.'</div><div class="tbcel3">'.$DS_DILUENTE.'</div><div class="tbcel2">'.$QT_DOSE_DILUENTE.'</div><div class="tbcel2">'.$DS_UNID_MEDIDA_DILUENTE.'</div></div>';

Follows where the user chooses the type of medication group, named protocol:

                               <div class="label">
                                <label>Protocolo</label><br />
                                <select name="protocolo" id="protocolo" class="protocolo input">
                                <option selected="selected" value="selecione">--- Selecione uma opção ---</option>
                                <?php
                                while (($exibe = oci_fetch_array($parsed_prot, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
                                                                        $CD_PROTOCOLO   = $exibe ['CD_PROTOCOLO'];  
                                                                        $NM_PROTOCOLO   = $exibe ['NM_PROTOCOLO'];
                                echo '<option value="'.$CD_PROTOCOLO.'">'.$NM_PROTOCOLO.'</option>';
                                } ?>
                                </select> 
                                </div>

Only after this choice, while should be executed.

  • Put the code you’re using for this.

  • Edited. Now with the code.

  • 1

    You have N ways to do this. You can load all templates into the page and hide using Divs. After selecting the automaker, Voce displays only the corresponding div. or ( recommended ) You can load the templates using ajax

  • Impossible to load all templates. There are more than 10,000 records. How I could use Ajax?

  • There are more than 10,000 records and then they come paginated, right? Still would have problem? Qnto ajax, can make a request for a page that returns to Oce this information only when clicked on the option you want...

  • Dude, just AJAX! Forget the rest.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.