I'm trying to set a dynamic variable name in each
method using conditional statement. I tried to assign a variable like we do in php, but it doesn't work. How to do that?
Here's my code
var owners_index_val_ar = $("#owners_index").val().split(',');
$.each(owners_index_val_ar, function(index, value){
$("#owner"+value+" :input").each(function(){
if($(this).val() == ""){
$(this).closest('.form-group').addClass("has-error");
error = true;
}
});
if(error == true){
var error_code_own_"+value = true; // this doesn't work
}
})