<button th:onclick="|javascript:handleDelete('${tmp.icode}')|">삭제</button>
<script>
function handleDelete(no){
if(confirm('삭제할까?')){
console.log(no);
// GET으로 삭제처리 주소창을 바꿈
// location.href="/ROOT/seller/deleteitem?code="+no
// post로 처리
// <form th:action="@{/seller/deleteitem}" method= "post"></form>을 만듦
const form = document.createElement("form");
form.method= "post";
form.action = "/ROOT/seller/deleteitem";
// <input type="text" name="code" value="전달되는 번호" />
const input = document.createElement("input");
input.name="code";
input.value = no;
// form document에 추가
form.appendChild(input);
// form document에 추가
document.body.appendChild(form);
// <input type="submit">를 누름
form.submit();
}
}
</script>