앱)check box to string

Posted by HULIA(휴리아)
2018. 11. 14. 20:53 프론트엔드/자바스크립트
selectedCheckbox to String
case1)
$(":checkbox[name='chbox1']:checked").each(function(idx, obj){
resultString += "|"+obj.value;
});

if(resultString != ""){
resultString = resultString.subString(1);
}
return resultString;

case2)
if($("input[name='checkboxname']").length <= 0){
    return;
}

var ids = "";
$("input[name='checkboxname']").each(function(){
        if($(this).prop("checked")) {
                ids += $(this).val() + "|";
        }
});