javascript - working with array(s) in JQuery -


i inputting values array in jquery 1,4,7,3. when displaying array values, displays 1,3,4,7.

i need 1,4,7,3 when inserted. code.

var selectedvalues = []; var $ctrls = $("[id*=chkprocessroutes] input:checkbox"); $("[id*=chkprocessroutes] input:checked").each(function () {     var l = parsefloat(($ctrls.index($(this))));     var ll = parsefloat(l) + 1;     selectedvalues.push(parsefloat(ll)); }); if (selectedvalues.length > 0) {     alert("selected value(s): " + selectedvalues.tostring()); } else {     alert("no item has been selected."); } 

try this:

var selectedvalues = $("[id*=chkprocessroutes] input:checked").map(function () {     return $(this).val(); }); if (selectedvalues.length > 0) {     alert("selected value(s): " + selectedvalues.tostring()); } else {     alert("no item has been selected."); } 

Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -