// delete event
function deleteArray() {
// get checked data-id
let checked = [];
for(let i = 0; i < check.length; i++) {
if(check[i].checked === true) {
checked.push(check[i].getAttribute('data-id'));
}
}
// if checked data-id is empty
if(checked.length === 0) {
alert('삭제할 게시물을 선택해주세요');
return false;
}
// array to json
let json = JSON.stringify(checked);
// if checked data-id is not empty
// make form method csrf token
let form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', '/board/notice');
// make input type hidden
let token = document.createElement('input');
token.type = 'hidden';
token.name = '_token';
token.value = '{{ csrf_token() }}';
form.appendChild(token);
// make input type hidden
let method = document.createElement('input');
method.type = 'hidden';
method.name = '_method';
method.value = 'delete';
form.appendChild(method);
// make input type hidden
let data = document.createElement('input');
data.type = 'hidden';
data.name = 'ids';
data.value = json;
form.appendChild(data);
document.body.appendChild(form);
form.submit();
}