๐Ÿ”•ํฌ์Šค๋ฉ”๋‰ด ์ทจ์†Œ

๊ถŒ์žฌํ˜„ยท2021๋…„ 8์›” 4์ผ
0

์ฃผ๋ฌธํ–ˆ๋˜ ๋ฉ”๋‰ด๋ฅผ ์ทจ์†Œ ์‹œ์— ๋ณ€๊ฒฝํ•ด์•ผ ํ–ˆ๋˜ ๊ฒƒ์— ๋Œ€ํ•œ ๊ธ€์ด๋‹ค.

๋ฉ”๋‰ด ์ทจ์†Œ

์ทจ์†Œ ํด๋ฆญ ์ „

์ทจ์†Œ ํด๋ฆญ ํ›„

๋ชฉ์  : ์ทจ์†Œ๋ฅผ ํด๋ฆญํ•˜๋ฉด ๊ทธ์— ๋”ฐ๋ผ ์ฃผ๋ฌธ๊ฐœ์ˆ˜์™€ ๊ธˆ์•ก๋„ ๋ณ€๊ฒฝ๋˜์•ผํ•œ๋‹ค.

ํ•„์š”ํ•œ ์ „์—ญ ๋ณ€์ˆ˜
var ordResCnt = 0 ; //์ด ์ฃผ๋ฌธ ๊ฐฏ์ˆ˜
var ordResPay = 0 ; // ์ด ์ฃผ๋ฌธ๊ธˆ์•ก

์ดˆ๊ธฐ๋ฒ„์ „

//์ฃผ๋ฌธ ์ทจ์†Œ
	$(".ord_area").on("click",".choice_cnl",function(){
		
		//์ทจ์†Œ ์‹œ ๊ฐฏ์ˆ˜ ์ œ๊ฑฐ
		ordResCnt -= $(this).parent().parent().children().children().eq(3).val();
		
		//์ทจ์†Œ ์‹œ ๊ธˆ์•ก ๋งˆ์ด๋„ˆ์Šค
		ordResPay -= ($(this).parent().parent().children().children().eq(3).val() * 
				$(this).parent().parent().children().children().eq(2).val()	)
		//์ฃผ๋ฌธ ์ œ๊ฑฐ
		$(this).parent().parent().remove();
		
		ordPay(); // ์ด ์ฃผ๋ฌธ๊ฐœ์ˆ˜์™€ ๊ฒฐ์ œ๊ธˆ์•ก ๋ณ€๊ฒฝ์— ์˜ํ•ด์„œ ๋‹ค์‹œ ๊ทธ๋ ค์ค€๋‹ค.
		cnt--;
		
	});

์ˆ˜์ •๋ฒ„์ „


//์ฃผ๋ฌธ ์ทจ์†Œ
		var mCnt = 0; //์ทจ์†Œ ๊ฐฏ์ˆ˜
		var mPrice = 0; // ์ทจ์†Œ ๊ฐ€๊ฒฉ
	$(".ord_area").on("click",".choice_cnl",function(){
		console.log("์ทจ์†Œ์‹œ ์ด๊ฐฏ์ˆ˜"+ordResCnt);
		console.log("์ทจ์†Œ์‹œ ์ด๊ธˆ์•ก"+ordResPay);
		//์ทจ์†Œ ๊ฐฏ์ˆ˜
			 mCnt=$(this).parent().parent().children().eq(3).children().val();
			console.log("mCnt "+mCnt);
		//์ทจ์†Œ ๊ฐ€๊ฒฉ
			 mPrice = $(this).parent().parent().children().eq(2).children().val();
			console.log("mPrice"+mPrice);
		
		//์ทจ์†Œ ์‹œ ๊ฐฏ์ˆ˜ ์ œ๊ฑฐ
			if(nowCnt != 0){
			ordResCnt -= mCnt;
		
		//์ทจ์†Œ ์‹œ ๊ธˆ์•ก ๋งˆ์ด๋„ˆ์Šค
			ordResPay -= mCnt * mPrice 
				
		//์ฃผ๋ฌธ ์ œ๊ฑฐ
			$(this).parent().parent().remove();
		
		//๊ธˆ์•ก ๋ณ€๊ฒฝ ์ƒํ™ฉ ๊ทธ๋ ค์ฃผ๊ธฐ
			ordPay();
		
		//์ทจ์†Œ ์ฃผ๋ฌธ ๋ฉ”๋‰ด
			cnlM =$(this).parent().parent().attr("mno");
		
		//ํ˜„์žฌ ์ฃผ๋ฌธ๊ฐœ์ˆ˜ ๋นผ๊ธฐ
			
				nowCnt--;
		
			} else{
				// ์ด์ฃผ๋ฌธ๊ฐœ์ˆ˜, ๊ฒฐ์ œ๊ธˆ์•ก ์ดˆ๊ธฐํ™”
				ordResPay = 0;
				ordResCnt = 0;
			}
		
		//์ฃผ๋ฌธ ์ž…๋‹ˆ๋‹ค ๋‹ค์‹œ ๋Œ๋ ค ๋†“๊ธฐ ํ•„์š”์—†์–ด์กŒ์ง€๋งŒ, ์‚ด๋ ค๋†“์ž ๊ณต๋ถ€์šฉ, ์…€๋ ‰ํ„ฐ ๊ณต๋ถ€์šฉ
		//$(".menu_area input[type='button'][mno='" + cnlM + "']").attr("class","menu_name");
      
		
	});

.choice_cnl์€ ์ทจ์†Œ๋ฒ„ํŠผ์˜ ํด๋ž˜์Šค๋ช… ์ด๊ณ  ๋‚ด๊ฐ€ ์ทจ์†Œ๋ฅผ ๋ˆ„๋ฅธ ๊ฒƒ์˜ ๊ฐ’๋งŒ ๋งˆ์ด๋„ˆ์Šค ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด this๋ฅผ ์‚ฌ์šฉํ–ˆ๊ณ , ์ฒ˜์Œ์— ์ทจ์†Œ ๊ฐฏ์ˆ˜์™€ ๊ธˆ์•ก์— ๋ณ€์ˆ˜๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค์ง€์•Š๊ณ  parent()์™€ children()์„ ๋‚จ๋ฐœํ•œ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ–ˆ๋”๋‹ˆ ,๋‚˜์ค‘์— ๋‚˜์™€ ๋‹ค๋ฅธ์‚ฌ๋žŒ์ด ์ด ์ฝ”๋“œ๋ฅผ ๋ดค์„ ๋•Œ ์ดํ•ดํ•  ์ˆ˜ ์žˆ์„๊นŒ? ๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ๋ฐ”๋กœ ๋ณ€์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ–ˆ๋‹ค. ์ด๋•Œ๋ถ€ํ„ฐ ๋ณ€์ˆ˜์™€ ์ฃผ์„์„ ์—ด์‹ฌํžˆ ๋‹ฌ๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค. ๋‚˜์™€ ๋ชจ๋‘๋ฅผ ์œ„ํ•ด์„œ

profile
ํ˜ธํ…”๋ฆฌ์–ด ์ถœ์‹  ๋น„์ „๊ณต์ž

0๊ฐœ์˜ ๋Œ“๊ธ€