▣ admin/cart/list.jsp ( .ajax() 이용 - DB 수정 처리 )
페이지 정보
본문
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/admin/include/header.jsp" %>
<style>
.ca_id {
width:70px;
border:0px;
}
.td_title{
text-align:center;
font-weight:bold;
}
.delete_btn {
border:1px solid red;
width:20px;
height:20px;
color:red;
cursor:pointer;
}
</style>
<table width=100% height=50 border=0>
<tr>
<td align=center style="color:#777;font-size:14px;font-weight:bold;">[장바구니관리]</td>
</tr>
</table>
<center>
<table width=700 border=0 align=center>
<tr>
<td>Total : ${count }</td>
<td align="right">
<form method="get">
<table border=0>
<tr>
<td>
<select name="field">
<option value="mb_id" <c:if test="${field == 'mb_id' }">selected</c:if>>아이디</option>
<option value="it_uid" <c:if test="${field == 'it_uid' }">selected</c:if>>상품코드</option>
</select>
<input name="search" value="${search }">
<button>검색</button>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<table width=700 border=0>
<tr bgcolor="#e5ecef" height="30">
<td class="td_title">No</td>
<td class="td_title">주문코드</td>
<td class="td_title">이미지</td>
<td class="td_title">상품코드</td>
<td class="td_title">아이디</td>
<td class="td_title">가격</td>
<td class="td_title">수량</td>
<td class="td_title">포인트</td>
<td class="td_title">상태</td>
<td class="td_title">등록일</td>
<td class="td_title">삭제</td>
</tr>
<c:set var="number" value="${number }" />
<c:set var="num" value="0" />
<c:forEach var="i" items="${v }">
<form action="modify" method="post">
<input type="hidden" name="number" value="${number }">
<input type="hidden" id="ct_uid" name="ct_uid" value="${i.ct_uid }">
<tr height="24">
<td width=40 align="center">${number }</td>
<td align="center">${i.od_id }</td>
<td align="center" style="padding-top:4px;"><img src="/upload_item/${i.file1 }" width=40></td>
<td align="center">${i.it_uid }</td>
<td align="center">${i.mb_id }</td>
<td align="center">${i.it_price }</td>
<td align="center">
<input type="button" value="-" onclick="qty_num(${num},'-')" style="width:22px;height:22px;">
<input id="qty" name="qty" value="${i.it_qty }" style="width:20px;height:20px;border:1px solid orange;text-align:center">
<input type="button" value="+" onclick="qty_num(${num},'+')" style="width:22px;height:22px;">
</td>
<td align="center">${i.it_point }</td>
<td align="center">${i.ct_status }</td>
<td align="center">${i.ct_date }</td>
<td align="center"><input type="button" value="x" class="delete_btn" onclick="location.href='delete?ct_uid=${i.ct_uid }'"></td>
</tr>
<tr><td colspan=11 height=1 bgcolor="#e5ecef"></td></tr>
</form>
<c:set var="number" value="${number - 1 }" />
<c:set var="num" value="${num + 1 }" />
</c:forEach>
</table>
<br>
<script>
//수량 증가,감소 처리
function qty_num(num,str){
var total = parseInt($("input[id=qty]:eq("+num+")").val());
var ct_uid = $("input[id=ct_uid]:eq("+num+")").val();
if(str == "-"){ //차감
if(total == 1){
alert("주문 최소 수량은 1개입니다.");
}else{
$("input[id=qty]:eq("+num+")").val(total - 1);
$.ajax({
url: "qty_update", //페이지 경로
type: "post",
dataType: "text",
data: "ct_uid="+ct_uid+"&str=m", //데이터 전달
error:function(){
alert("실패");
},
success:function(text){
}
});
}
}else{ //증가
$("input[id=qty]:eq("+num+")").val(total + 1);
$.ajax({
url: "qty_update", //페이지 경로
type: "post",
dataType: "text",
data: "ct_uid="+ct_uid+"&str=p", //데이터 전달
error:function(){
alert("실패");
},
success:function(text){
}
});
}
}
</script>
<!-- 페이징 처리 -->
<style>
.page_on {
padding:0px 5px;
color:red;
border:1px solid red;
font-weight:bold;
}
.page_off {
padding:0px 5px;
color:black;
border:1px solid black;
}
</style>
<table width=700 border=0>
<tr>
<td>
<c:if test="${count>0 }">
<c:set var="pageCount" value="${count / pageSize + (count % pageSize == 0 ? 0 : 1) }" />
<fmt:parseNumber var="pageCount" value="${pageCount }" integerOnly="true" />
<!-- fmt:parseNumber : 문자열을 숫자로 변환해 주는 기능을 제공하는 태그 -->
<!-- integerOnly : true , false 정수만 출력할 것인지를 묻는 속성 -->
<!-- 2개의 변수 초기화 -->
<c:set var="startPage" value="${1 }" />
<c:set var="pageBlock" value="${3 }" />
<!-- 다음 페이지 블럭이 존재 할 경우 startPage 값 변경 부분-->
<c:if test="${pageNum > pageBlock }">
<!-- 결과를 정수형으로 리턴 받아야 하기 대문에 fmt -->
<fmt:parseNumber var="result" value="${pageNum / pageBlock - (pageNum % pageBlock == 0 ? 1:0) }" integerOnly="true"/>
<c:set var="startPage" value="${result * pageBlock + 1 }" />
</c:if>
<!-- endPage 값 설정 부분 -->
<c:set var="endPage" value="${startPage + pageBlock - 1 }" />
<c:if test="${endPage > pageCount }">
<c:set var="endPage" value="${pageCount }" />
</c:if>
<!-- 이전 링크 -->
<c:if test="${startPage > pageBlock }">
<a href="list?pageNum=${startPage - pageBlock }&field=${field}&search=${search}">[이전] </a>
</c:if>
<!-- 페이징 링크 -->
<c:forEach var="i" begin="${startPage }" end="${endPage }">
<c:choose>
<c:when test="${pageNum == i }">
<a href="list?pageNum=${i }&field=${field}&search=${search}"><span class="page_on"><font color=red><b>${i }</b></font></span></a>
</c:when>
<c:otherwise>
<a href="list?pageNum=${i }&field=${field}&search=${search}"><span class="page_off">${i }</span></a>
</c:otherwise>
</c:choose>
</c:forEach>
<!-- 다음 링크 -->
<c:if test="${endPage < pageCount }">
<a href="list?pageNum=${startPage + pageBlock }&field=${field}&search=${search}">[다음] </a>
</c:if>
</c:if>
</td>
<td align="right"></td>
</tr>
</table>
<br>
</center>
<%@ include file="/admin/include/footer.jsp" %>
- 이전글admin/cart/list.jsp 23.03.25
- 다음글● admin - 상품 관리 ( 수정 ) 23.03.24
댓글목록
등록된 댓글이 없습니다.