javascript - how to add value to array and separate by (vertical bar) not by comma -
so wanted checked value array , add vertical bar instead of comma separate each value, there way jquery map .get() function, links or suggestions ye can provide appreciate it. thank in advance.
$('input[type=checkbox][name=groupabc]').change(function(){ var checkedvalues = $('input[name="groupabc"]:checked').map(function() { return $(this).attr('id'); }).get(); alert(checkedvalues); });
for above code logic got [a,b,c,d,e,f,g]
what want [a|b|c|d|e|f|g]
what want [a|b|c|d|e|f|g]
$('input[type=checkbox][name=groupabc]').change(function(){ var checkedvalues = $('input[name="groupabc"]:checked').map(function() { return $(this).attr('id'); }).get().join("|"); alert([checkedvalues]); });
var arr = ["a", "b", "c", "d", "e", "f", "g"]; var res = [arr.join("|")]; document.write(json.stringify(res));
Comments
Post a Comment