How can I set "independent conditions" in jQuery? I have 13 different possibilities and I just want to execute them independently of each other in my program, here is my code;
$('#account-form1 input#odenen,#account-form2 input#odenen').one("blur",function(){
var bakiye = parseFloat($("#bakiye").val());
var borcu = parseFloat($("#borcu").val());
var odenen = parseFloat($("#odenen").val());
var alacak = parseFloat($("#alacak").val());
// 1.possibilty
if((borcu == 0) && (odenen > bakiye)){
var current_alacak = parseFloat($('#alacak').val());
$('#alacak').val(current_alacak + (odenen - bakiye));
// 2.possibilty
}else if((borcu > odenen) && (bakiye > odenen)){
var current_borcu_2 = parseFloat($('#borcu').val());
$('#borcu').val((current_borcu_2 - odenen) + (bakiye));
// 3.possibilty
}else if((borcu > 0) && (borcu < odenen) && (bakiye > odenen)){
$('#borcu').val(bakiye - (odenen - borcu));
// 4.possibilty
}else if((borcu > 0) && (odenen > (borcu + bakiye))){
var current_alacak_2 = parseFloat($('#alacak').val());
$('#alacak').val(current_alacak_2 + (odenen - (bakiye + borcu)));
$('#borcu').val(0);
// 5.possibilty
}else if((borcu > 0) && (borcu < odenen) && (odenen > bakiye)){
$('#borcu').val(bakiye - (odenen - borcu));
// 6.possibilty
}else if(odenen < bakiye){
var current_borcu = parseFloat($('#borcu').val());
$('#borcu').val(current_borcu + (bakiye - odenen));
// 7.possibilty
}else if((borcu > 0) && (odenen = (bakiye + borcu))){
$('#borcu').val(0);
// 8.possibilty (this one is not working right because of another condition)
}else if((borcu == 0) && (alacak > 0) && (bakiye = (odenen + alacak))){
$('#alacak').val(0);
}
***goes on like this..***
Conditions may executing same time and affecting result :/
Aucun commentaire:
Enregistrer un commentaire