Last active
August 29, 2015 14:00
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var myJson = new Array(); | |
$(document).ready(function() { | |
// Pas en asynchrone pour le dev (debug) | |
/*$.ajaxSetup({ | |
async: false | |
}); | |
*/ | |
// Recupère les infos au format JSON et remplit la select etablissement avec les infos adéquates | |
$.getJSON( "{{url_base}}jsoninfos/", function( data ) { | |
myJson = data; | |
}); | |
// Remplit "dynamiquement" la select des formations en fonction de l'établissement choisit | |
$('#etablissement').on('change', function() { | |
for(var i = 0; i < myJson.length; i++) { | |
if(myJson[i].id == $(this).val()) { | |
$('#formation').html('<option value="0">Selectionnez formation</option>'); | |
$.each(myJson[i].formations, function (index, formation) { | |
$("#formation").append('<option value="'+formation.id+'">'+formation.for_nom+'</option>'); | |
}); | |
} | |
} | |
}); | |
}); | |
</script> | |
/* | |
Example of JSON for this script : | |
[ | |
{ | |
"id":"1", | |
"etab_nom":"IUT DE TRUC", | |
"formations":[ | |
{ | |
"id":"5", | |
"for_nom":"LICENCE PRO URBANISME", | |
}, | |
{ | |
"id":"98", | |
"for_nom":"D.U. GEST. OPER. LOGIST.", | |
} | |
] | |
}, | |
{ | |
"id":"2", | |
"etab_nom":"CENTRE UNIVERSITAIRE LETTRES", | |
"formations":[ | |
{ | |
"id":"67", | |
"for_nom":"LICENCE ANGLAIS", | |
}, | |
{ | |
"id":"78", | |
"for_nom":"LICENCE ESPAGNOL", | |
} | |
] | |
}, | |
{ | |
"id":"3", | |
"etab_nom":"CENTRE UNIVERSITAIRE CHIMIE", | |
"formations":[ | |
{ | |
"id":"90", | |
"for_nom":"LICENCE BIOCHIMIE", | |
}, | |
{ | |
"id":"68", | |
"for_nom":"LICENCE CHIMIE ORGANIQUE", | |
} | |
] | |
} | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment