Commit aea53678 by Alonso Moreno Postigo

[EDIT] ListadoPersona arreglado

parent 95a1d028
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$(document).ready(function () {
init();
validarSelect();
});
function init() {
listarDepartamento();
listarProvincia();
listarDistrito();
}
function listarDepartamento() {
$.ajax({
type: 'POST',
url: '../UbigeoServlet?accion=listarDepartamento',
beforeSend: function (xhr) {
},
success: function (data, textStatus, jqXHR) {
var status = data.status;
var departamentos = data.data.departamentos;
if (status) {
var select_departamento = '<option value="0">[ SELECCIONE ]</option>';
for (var i in departamentos) {
select_departamento += '<option value="' + departamentos[i].codigoDepartamento + '">' + departamentos[i].nombreDepartamento + '</option>';
}
$('#select_departamento').html(select_departamento);
$('#select_departamento').selectpicker('refresh');
} else {
console.log('no hay data prro');
}
},
complete: function (jqXHR, textStatus) {
}
});
}
function listarProvincia() {
$('#select_departamento').on('change', function () {
var json = {
codigoDepartamento: $('#select_departamento').val()
};
$.ajax({
type: 'POST',
url: '../UbigeoServlet?accion=listarProvincia',
dataType: 'json',
data: {json: JSON.stringify(json)},
beforeSend: function (xhr) {
},
success: function (data, textStatus, jqXHR) {
var status = data.status;
var provincias = data.data.provincias;
if (status) {
var select_provincia = '<option value="0">[ SELECCIONE ]</option>';
for (var i in provincias) {
select_provincia += '<option value="' + provincias[i].codigoProvincia + '">' + provincias[i].nombreProvincia + '</option>';
}
$('#select_provincia').html(select_provincia);
$('#select_provincia').selectpicker('refresh');
} else {
console.log('no hay data prro');
}
},
complete: function (jqXHR, textStatus) {
}
});
});
}
function listarDistrito() {
$('#select_provincia').on('change', function () {
var json = {
codigoDepartamento: $('#select_departamento').val(),
codigoProvincia: $('#select_provincia').val()
};
$.ajax({
type: 'POST',
url: '../UbigeoServlet?accion=listarDistrito',
dataType: 'json',
data: {json: JSON.stringify(json)},
beforeSend: function (xhr) {
},
success: function (data, textStatus, jqXHR) {
var status = data.status;
var distritos = data.data.distritos;
if (status) {
var select_distrito = '<option value="0">[ SELECCIONE ]</option>';
for (var i in distritos) {
select_distrito += '<option value="' + distritos[i].codigoDistrito + '">' + distritos[i].nombreDistrito + '</option>';
}
$('#select_distrito').html(select_distrito);
$('#select_distrito').selectpicker('refresh');
} else {
console.log('no hay data prro');
}
},
complete: function (jqXHR, textStatus) {
}
});
});
}
function validarSelect() {
$('#select_departamento').on('change', function () {
// debugger;
var select_departamento = $('#select_departamento').val();
if (select_departamento === '0') {
$('#select_provincia').html('<option value="0">[ SELECCIONE ]</option>');
$('#select_distrito').html('<option value="0">[ SELECCIONE ]</option>');
$('#select_provincia').selectpicker('refresh');
$('#select_distrito').selectpicker('refresh');
} else {
$('#select_provincia').val(0);
$('#select_distrito').val(0);
$('#select_distrito').val('<option value="0">[ SELECCIONE ]</option>');
$('#select_provincia').selectpicker('refresh');
$('#select_distrito').selectpicker('refresh');
}
});
}
\ No newline at end of file
......@@ -31,7 +31,7 @@
<div class="col-md-4">
<div class="form-group">
<label class="text-uppercase">departamento<span class="text-danger"> (*)</span></label>
<select class="bootstrap-select" data-width="100%">
<select id="select_departamento" class="bootstrap-select" data-width="100%">
<option value="0">[ SELECCIONE ]</option>
</select>
</div>
......@@ -39,7 +39,7 @@
<div class="col-md-4">
<div class="form-group">
<label class="text-uppercase">provincia<span class="text-danger"> (*)</span></label>
<select class="bootstrap-select" data-width="100%">
<select id="select_provincia" class="bootstrap-select" data-width="100%">
<option value="0">[ SELECCIONE ]</option>
</select>
</div>
......@@ -47,7 +47,7 @@
<div class="col-md-4">
<div class="form-group">
<label class="text-uppercase">distrito<span class="text-danger"> (*)</span></label>
<select class="bootstrap-select" data-width="100%">
<select id="select_distrito" class="bootstrap-select" data-width="100%">
<option value="0">[ SELECCIONE ]</option>
</select>
</div>
......@@ -75,6 +75,7 @@
<script type="text/javascript" src="../plantilla/assets/js/pages/form_bootstrap_select.js"></script>
<!--js-->
<script src="../js/pages/ubigeo.js" type="text/javascript"></script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment