[Spring][쇼핑몰 프로젝트][18] 상품 등록 - 입력란 수정& 외래키 설정

https://kimvampa.tistory.com/201
This commit is contained in:
SeoJin Kim
2021-03-31 17:30:06 +09:00
parent ee09bf145e
commit 1ad5d51b93
6 changed files with 103 additions and 11 deletions

View File

@@ -111,8 +111,10 @@
<label>상품 할인율</label>
</div>
<div class="form_section_content">
<input name="bookDiscount">
<span class="ck_warn bookDiscount_warn">상품 할인율을 입력해주세요.</span>
<input id="discount_interface" maxlength="2" value="0">
<input name="bookDiscount" type="hidden" value="0">
<span class="step_val">할인 가격 : <span class="span_discount"></span></span>
<span class="ck_warn bookDiscount_warn">1~99 숫자를 입력해주세요.</span>
</div>
</div>
<div class="form_section">
@@ -179,7 +181,7 @@ $("#enrollBtn").on("click",function(e){
let cateCode = $("select[name='cateCode']").val();
let bookPrice = $("input[name='bookPrice']").val();
let bookStock = $("input[name='bookStock']").val();
let bookDiscount = $("input[name='bookDiscount']").val();
let bookDiscount = $("#discount_interface").val();
let bookIntro = $(".bit p").html();
let bookContents = $(".bct p").html();
@@ -240,7 +242,7 @@ $("#enrollBtn").on("click",function(e){
stockCk = false;
}
if(bookDiscount < 1 && bookDiscount != ''){
if(!isNaN(bookDiscount)){
$(".bookDiscount_warn").css('display','none');
discountCk = true;
} else {
@@ -414,6 +416,44 @@ $("#enrollBtn").on("click",function(e){
});
/* 할인율 Input 설정 */
$("#discount_interface").on("propertychange change keyup paste input", function(){
let userInput = $("#discount_interface");
let discountInput = $("input[name='bookDiscount']");
let discountRate = userInput.val(); // 사용자가 입력한 할인값
let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값
let goodsPrice = $("input[name='bookPrice']").val(); // 원가
let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격
if(!isNaN(discountRate)){
$(".span_discount").html(discountPrice);
discountInput.val(sendDiscountRate);
}
});
$("input[name='bookPrice']").on("change", function(){
let userInput = $("#discount_interface");
let discountInput = $("input[name='bookDiscount']");
let discountRate = userInput.val(); // 사용자가 입력한 할인값
let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값
let goodsPrice = $("input[name='bookPrice']").val(); // 원가
let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격
if(!isNaN(discountRate)){
$(".span_discount").html(discountPrice);
}
});
</script>
</body>

View File

@@ -194,6 +194,12 @@ input[name='publeYear'] {
font-weight: 300;
}
.step_val{ /* 할인 가격 문구 */
display: block;
padding-top: 5px;
font-weight: 500;
}
/* 버튼 영역 */
.btn_section{

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Mon Mar 29 18:10:20 KST 2021
#Wed Mar 31 15:59:23 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa
m2e.projectName=VamPa
groupId=com.vam

View File

@@ -111,8 +111,10 @@
<label>상품 할인율</label>
</div>
<div class="form_section_content">
<input name="bookDiscount">
<span class="ck_warn bookDiscount_warn">상품 할인율을 입력해주세요.</span>
<input id="discount_interface" maxlength="2" value="0">
<input name="bookDiscount" type="hidden" value="0">
<span class="step_val">할인 가격 : <span class="span_discount"></span></span>
<span class="ck_warn bookDiscount_warn">1~99 숫자를 입력해주세요.</span>
</div>
</div>
<div class="form_section">
@@ -179,7 +181,7 @@ $("#enrollBtn").on("click",function(e){
let cateCode = $("select[name='cateCode']").val();
let bookPrice = $("input[name='bookPrice']").val();
let bookStock = $("input[name='bookStock']").val();
let bookDiscount = $("input[name='bookDiscount']").val();
let bookDiscount = $("#discount_interface").val();
let bookIntro = $(".bit p").html();
let bookContents = $(".bct p").html();
@@ -240,7 +242,7 @@ $("#enrollBtn").on("click",function(e){
stockCk = false;
}
if(bookDiscount < 1 && bookDiscount != ''){
if(!isNaN(bookDiscount)){
$(".bookDiscount_warn").css('display','none');
discountCk = true;
} else {
@@ -264,7 +266,7 @@ $("#enrollBtn").on("click",function(e){
contentsCk = false;
}
/* 최종확인 */
/* 최종 확인 */
if(bookNameCk && authorIdCk && publeYearCk && publisherCk && cateCodeCk && priceCk && stockCk && discountCk && introCk && contentsCk ){
//alert('통과');
enrollForm.submit();
@@ -414,6 +416,44 @@ $("#enrollBtn").on("click",function(e){
});
/* 할인율 Input 설정 */
$("#discount_interface").on("propertychange change keyup paste input", function(){
let userInput = $("#discount_interface");
let discountInput = $("input[name='bookDiscount']");
let discountRate = userInput.val(); // 사용자가 입력한 할인값
let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값
let goodsPrice = $("input[name='bookPrice']").val(); // 원가
let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격
if(!isNaN(discountRate)){
$(".span_discount").html(discountPrice);
discountInput.val(sendDiscountRate);
}
});
$("input[name='bookPrice']").on("change", function(){
let userInput = $("#discount_interface");
let discountInput = $("input[name='bookDiscount']");
let discountRate = userInput.val(); // 사용자가 입력한 할인값
let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값
let goodsPrice = $("input[name='bookPrice']").val(); // 원가
let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격
if(!isNaN(discountRate)){
$(".span_discount").html(discountPrice);
}
});
</script>
</body>

View File

@@ -194,6 +194,12 @@ input[name='publeYear'] {
font-weight: 300;
}
.step_val{ /* 할인 가격 문구 */
display: block;
padding-top: 5px;
font-weight: 500;
}
/* 버튼 영역 */
.btn_section{

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Mon Mar 29 18:10:21 KST 2021
#Wed Mar 31 15:59:24 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa_MySQL
m2e.projectName=VamPa_MySQL
groupId=com.vam