Triple dynamic combo

Asked

Viewed 305 times

1

Good afternoon,

Next, I’m doing a dynamic combo with three selects where I have offending area, status and substatus. I pull the offending area and he pulls the cute status. This script was an adaptation of one I found on google, ai i wanted to deploy a third select but as no javascript manjo am travada aqui.

The index part without php looks like this:

            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <script src="jquery-1.7.2.min.js" type="text/javascript"></script>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
            <script type="text/javascript"> 


            //funcao para carregamento do status de acordo com area ofensora - Combo dinamico

            function buscar_status(){
                  var AreaOfensora = $('#AreaOfensora').val();
                  if(AreaOfensora){
                    var url = 'ajax_buscar_status.php?AreaOfensora='+AreaOfensora;
                    $.get(url, function(dataReturn) {
                      $('#load_status').html(dataReturn);
                    });
                  }
                }

            //funcao para carregamento do substatus de acordo com status e area ofensora - Combo dinamico

            function buscar_sub(){
                  var AreaOfensora = $('#AreaOfensora').val();
                  var status = $('#status').val();
                  if(status){
                    var url = 'ajax_buscar_substatus.php?AreaOfensora='+AreaOfensora+'&status='+status;
                    $.get(url, function(dataReturn) {
                      $('#load_substatus').html(dataReturn);
                    });
                  }
                }

            </script>
            </head>
            <body>
            <form method="POST" action="envia.php"> 

                        <p><div class="div3"><label>Área ofensora:</label><br>
                            <select name="AreaOfensora" id="AreaOfensora" onblur="ValidaEntrada(this,'combo');" class="txt2comboboxpadrao bradius" onchange="buscar_status()">
                                    <option value="">Selecione...</option>
                                        <?php foreach ($arrAreaOfensora as $value => $name) 
                                        {
                                            echo "<option value='{$value}'>{$name}</option>";
                                        }
                                        ?>
                                </select></p></div>


                        <p><div class="div3"><div id="load_status"><label>Status</label><br>
                            <select name="status" id="status" onblur="ValidaEntrada(this,'combo');" class="txt2comboboxpadrao bradius" onchange="buscar_sub()">
                                <option value="">Selecione o status</option>
                            </select>
                        </p></div></div>


                        <p><div class="div3"><div id="load_substatus"><label>Substatus</label><br>
                            <select name="substatus" id="substatus" onblur="ValidaEntrada(this,'combo');" class="txt2comboboxpadrao bradius">
                                <option value="">Selecione o substatus</option>
                            </select>
                        </p></div></div>


                        <input type="submit" value="Cadastrar" id="cadastrar" name="cadastrar">

            </form>         

            </body>
            </html>         

The page I call to search the data in the database to fill in the select is working right in both functions, because I tested sending the data manually by the url and rolled legal, but when I change the status it does not call the function of the third select :(. When I call the two functions in the first select (for testing) changes the two combos, but I need the status to have the substatus.

Can anyone help me?? Please!! Please please Thank you very much!

  • 1

    You have 3 selects, where only the first is filled the second will be populated according to the choice made in the first the third according to the choice made in the second select. That’s right?

  • Aloísio, the third depends on the choice of the first and the second. I need the two data, are two conditions in the Where of the third.

  • Next... you are calling the function to make the ajax request to fill the third when you make the choice in the second and click on another part of the page (onBlur) and then you use the parameters obtained in the first select and the second.. so that the result of this request will populate the third.

  • The suggestion would be you use onChange, then it makes the request when you change and not when you go to another part of the page, this is when you make the choice in the list it makes the request. But there may be other problems perhaps the script is not prepared to be able to assemble the condition and so do not populate the third.

  • Thank you Aloisio, but I am using the onchange itself, to call both the first function (second combo) and the second. I wonder if the second function (search_sub) is misspelled so it is not running.

  • Let’s rsrsr a lot of interaction but the important thing is to help I’ll take a look at the code calmly and I’ll give you an opinion

  • Can someone help me???

  • Gee rsrsrs I just forgot :D I want to help, but I need to see things like the backend and see how the codes are.. work with this for years and bizarre things have already made my codes stop working, (an invisible line break signaling) so there is a way to collaboratively gather these codes and provide the solution you need?

  • Aloisio!!! hahahaha Thank you for your willingness! What do you suggest? I can send you everything somehow, I haven’t even implanted it yet, I want to make the combos work and then put it in the place where I will actually use it. I can send you codes and tables.

  • You can send it to [email protected], tmb is skype account. fds are usually quieter and we can try to solve this stop :D

Show 5 more comments
No answers

Browser other questions tagged

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