dimanche 1 février 2015

jQuery .val() doesn't work with array of class


I am trying to get some values from a form with jQuery, and users can add as many fields as they want to this form. So i made a function to get these values back in order to send them with $.post. But as you can see, i have to create a temporary table and i feel bad for doing this, i'm sure there is a better solution... Can somebody help me? Thx a lot and sorry for my bad English.



var pc_add_service=[];
var pc_add_argent=[];

var temp_add_service=$('.pc_add_service');
var temp_add_argent=$('.pc_add_argent');

var c= temp_add_service.length;

for (var i = 0; i < c; i++) {
pc_add_service[i]=temp_add_service[i].value;
pc_add_argent[i]=temp_add_argent[i].value;
}

alert(pc_add_service);
alert(pc_add_argent);




Aucun commentaire:

Enregistrer un commentaire