function qp(qp,id){
var qpresult = qp[id];
}
function tarif(tarif,id){
var tarifresult = tarif[id];
}
$(document).ready(function(){
$('#salle').change(function(){
//any select change on the dropdown with id salle trigger this code
$("#disciplines > option").remove(); //first of all clear select items
var salle_nom = $('#salle').val(); //here i'm taking salle id of the selected one.
$.ajax({
type: "POST",
url: "http://localhost/public_html/admin/dropdown_salle/get_cities/"+salle_nom, //here i'm calling our user controller and get_disciplines method with the salle_id
dataType : "json",
success: function(disciplines) //we're calling the response json array 'disciplines'
{
var discipline = new Array();
var qp = new Array();
var tarif = new Array();
for (i=0; i<disciplines.length; ++i) {
// Now i got 3 arrays from the two dimentional array from the db. one for 'disciplines', one for 'qp_agent' = (pourcentage a payé pour l'agent), and the last for 'tarif'(tarif par mois de la cette discipline dans la salle choisi).
discipline[i] = disciplines[i].discipline+' pour '+disciplines[i].categorie_tarif;
qp[i] = disciplines[i].qp_agent;
tarif[i] = disciplines[i].tarif;
}
$.each(discipline,function(id,value)
//here i'm doing a foeach loop round each value with id as the key and value as the value
{
var opt = $('<option />');
// here i'm creating a new select option with for each value
opt.val(id);
opt.text(value);
$('#cities').append(opt);
//here i will append these...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.