1
I’m trying to change a script I have for weather forecast, but unsuccessfully, today the user selects an option in select and clicks the button to run the search, what I’m trying to do is use Onchange to shorten the operation.
What I tried unsuccessfully was this:
onchange="document.getElementById('frmBusca')
The script is like this today:
<form id="frmBusca" class="sky-form clearfix" action="" method="post">
<div class="row">
<div class="col-md-12">
<div class="fancy-form fancy-form-select">
<select name="Cidade" class="form-control" id="Cidade" tabindex="1" >
<option value="0">Cidade</option>
<?php foreach ($ResCidade as $Cidade) { ?>
<option value="<?php echo $Cidade->IdCidade; ?>"><?php echo $Cidade->Descricao; ?></option>
<?php } ?>
</select>
<i class="fancy-arrow"></i> </div>
</div>
</div>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<button class="btn btn-primary pull-right btn-block">PESQUISAR</button>
</div>
<div class="col-md-3"></div>
</div>
The one being called:
<script type="text/javascript">
// BUSCA DADOS DO CLIMA
$(function() {
$("#frmBusca").validate({
submitHandler: function(form) {
$.ajax({
type: 'POST',
url: 'pBuscaClima.php',
data: data,
dataType: 'html',
success: function(response)
// EXIBINDO O RETORNO DAS INFORMAÇÕES
$("#msgClima").html(response);
// RESETANDO A FUNÇÃO
// _toggle();
$('#frmBusca').each(function() {
this.reset();
});
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(xhr, ajaxOptions, thrownError);
$("#msgClima").html('<div class="alert alert-danger fade in"><button class="close" data-dismiss="alert">×</button><i class="fa-fw fa fa-times"></i><strong>ATENÇÃO!</strong> Ocorreu um erro ao tentar enviar a pergunta. Contate o suporte técnico.</div>');
}
});
return false;
}
});
});
You need this function in validate?
– Bruno Heringer