In my form, I have multiple fields (hidden text boxes) which has the same name (eform_id). (For example I have 7 hidden textboxes which contains values like this 1234,-1235,1236,1237,-1238,-1239,1240).
I am getting those values to my js file like this.
var eformDetailIds=$("[name=eform_id]").map(function(){
return $(this).val() }).get();
Now my requirement is I have to separate this eformDetailIds into two lists..(or a string of comma separated values) so that first list contains all positive values and second list contains all negative values.
Please help me with suitable code which resolves my problem.
Well:
If you return
nullfrom the “.map()” callback, then nothing is added to the result array.You could also do this with a simple(r)
forloop:If you want a comma-separated string form, just call “.join()” on the array: