Onchange event with two selects

0

Well, guys, it's a problem. Function ajax to trying to load a list of clients and each client there is a property for creating reports.

Ajax code:

function CarregaPropriedades(Cliente)
{
    if(Cliente){
        var myAjax = new Ajax.Updater("PropriedadesAjax","buscar_propriedades.php?pesquisador="+Cliente,
        {
            method : "get"
        }) ;
    }

}

Property search code.

<?
    $cliente = $_GET['pesquisador'];
    $dao = new Propriedade();
    $listar_com_pesquisador = $dao->listar_propriedades_cliente($cliente);
?>
<select name="propriedade" id="propriedade">
    <?php foreach($listar_com_pesquisador as $res){
    ?>
        <option value="<?php echo $res->Id?>"><?php echo $res->Nome?></option>
<?php }?>
</select>

I made the debug with firebug in firefox it presents the following error.

ReferenceError: Ajax is not defined

LoadProperties () form_bo ... olo.php (line 73)

onchange () form_bo ... olo.php (line 1)

myAjax = new Ajax.Updater ("Ajax Properties", "search_properties.php? searcher=" ...

What now? I do not know what to do, waiting for opinions and suggestions for resolutions.

    
asked by anonymous 19.10.2015 / 15:01

1 answer

0

I had even forgotten to respond, but it was resolved The Prototype library has been inserted and this issue has been resolved. The complete code to load a client and a property specifies according to the selected client: Variables $ edit comes from the $ _GET that receives the client ID, in case the administrator wants to edit it.

    <div class="form-inline">
        <label>Selecione um cliente:</label>
        <select style="min-width:65%" onchange="CarregaPropriedades(this.value)"  name="Id_cliente" id="Clientess" class="form-control">    
            <option> Selecione o cliente </option>
            <?php foreach ($clientes as $cliente) { ?>  

                <option <?php
                if (isset($editar)) {
                    if ($boletim->Id_cliente == $cliente->Id) {
                        echo "selected=selected";
                        $cliente_selecionado = $cliente->Id;
                    }
                }
                ?>

                    style="width: 900px;" name="<?php echo $cliente->Id; ?>" value="<?php echo $cliente->Id; ?>" ><?php echo $cliente->Nome; ?></option>
                }
            <?php } ?>
        </select>
        <a href="form_cliente.php" class="btn btn-info" role="button">Cadastrar novo cliente</a>
    </div>

    <hr />


    <div class="form-inline" id="PropriedadesAjax">
        <label>Selecione uma propriedade:</label>
        <select style="min-width:61.2%" name="Propriedade" id="Propriedade" class="form-control">    

            <?php
            if (isset($editar)) {
                $propriedades = $daoPropriedades->listar_propriedades_cliente($cliente_selecionado);
                foreach ($propriedades as $propriedade) {
                    ?> 
                    <option   <?php
            if ($boletim->Propriedade == $propriedade->Id) {
                echo "selected=selected";
            }
                    ?> value="<?php echo $propriedade->Id; ?>" name="Propriedade" id="Propriedade"><?php echo $propriedade->Nome; ?></option>  
                        <?php
                    }
                } else {
                    echo '<option value="">Selecione a propriedade</option>';
                }
                ?>
        </select>

    </div>

    <hr />

    <div class="form-inline">
        <label>Selecione um pesquisador:</label>
        <select style="min-width:61.56%" name="Pesquisador" id="Pesquisador" class="form-control">    
            <option> Selecione um pesquisador responsável </option>
            <?php foreach ($pesquisadores as $pesquisador) { ?>  

                <option <?php
                if (isset($editar)) {
                    if ($boletim->Pesquisador == $pesquisador->Login) {
                        echo "selected=selected";
                    }
                }
                ?>

                    style="width: 750px;" id="optionCliente" name="<?php echo $pesquisador->Login; ?>" value="<?php echo $pesquisador->Login; ?>" ><?php echo $pesquisador->Login; ?></option>

            <?php } ?>
        </select>
        <a href="form_pesquisador.php" class="btn btn-info" role="button">Cadastrar novo pesquisador</a>
    </div>

Any questions just ask me about.

    
11.11.2015 / 13:38