Skip to content

Instantly share code, notes, and snippets.

@jyr
Created May 29, 2009 18:15
Show Gist options
  • Save jyr/120113 to your computer and use it in GitHub Desktop.
Save jyr/120113 to your computer and use it in GitHub Desktop.
$(document).ready(function(){
//Inicializando variables del select
var parentNode = $('select#t_comprobacion').val();
var eventRun = false;
$('select#t_comprobacion').change(function (){
if(!eventRun && parentNode != $('select#t_comprobacion').val()){
$.getJSON("/gastos/ajax/json_tipos/"+$(this).val(), function(j){
var options = '<option>Todos los gastos</option>';
for (var i = 0; i < j.length; i++) {
options += '<option value="' + j[i].ID_DETALLES_GASTO + '">' + j[i].DESCRIPCION_GASTO + '</option>';
}
$("select#gastos").html(options);
eventRun = true;
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment