SECTION 3. 조건문
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous"></script>
<!-- 슬라이더 페이지 -->
<script>
//첫번쨰 ready이벤트
$(document).ready(function(){
let width=$('[data-role="slider"]').attr('data-width');
let height=$('[data-role="slider"]').attr('data-height');
let count=$('[data-role="slider"] div.item').length;
$('[data-role="slider"]').css({
position: 'relative',
overflow:'hidden',
left: 200,
width:width,
height:height
}).find('.container').css({
position: 'absolute',
width:count*width,
overflow:'hidden'
}).find('.item').css({
width:width,
height:height,
float: 'left'
});
// 변수를 선언합니다.
let currentPage=0;
let changePage =function(){
$('[data-role="slider"]>.container').animate({
left:-currentPage*width},500); //500은 시간
};
//이벤트를 연결합니다.
$('#left-button').click(function(){
if(currentPage>0){
//왼쪽으로 이동 첫장일때는 눌러도 아무일도 일어나지않음. 한장이라도 넘긴 다음부터는 왼쪽으로 갈 수 있음
currentPage= currentPage-1;
changePage();
}
});
$('#right-button').click(function(){
if(currentPage<count-1){
// 오른쪽으로 이동
currentPage= currentPage+1;
changePage();
}
});
});
</script>
<script>
//환영메세지.
const username=prompt('이름을 입력해주세요', '이름') //prompt함수는 사용자로부터 내용을 입력받아서 사용
// 출력합니다
alert(username+'님 환영합니다!');
$(document).ready(function(){
$('#header').html('❤️ '+username+' 님의 도시락'+'❤️');
})
</script>
<script>
//전화번호 넘어가기 왜 안되는지 모르겠음. 차차수정
window.onload = function () {
// 문서 객체를 선택합니다. body에 input을 찾아서 배열만들어짐.
let input_1 = document.getElementsByClassName('phone')[0];
let input_2 = document.getElementsByClassName('phone')[1];
let input_3 = document.getElementsByClassName('phone')[2];
// input_1 onkey 키보드를 누르는 순간
input_1.onkeydown = function () {
if (3 <= input_1.value.length) {
input_2.focus();
}
};
// input_2
input_2.onkeydown = function (event) {
let evt = event || window.event;
// 사용자의 입력이 '백스페이스'이고 입력된 글자가 없을 때
if (evt.keyCode == 8 && input_2.value.length == 0) {
input_1.focus();
} else if (4 <= input_2.value.length) {
input_3.focus();
}
};
// input_3
input_3.onkeydown = function (event) {
// 이벤트 객체를 추출합니다.
let evt1 = event || window.event;
// 사용자의 입력이 '백스페이스'이고 입력된 글자가 없을 때
if (evt1.keyCode == 8 && input_3.value.length == 0) {
input_2.focus();
} else if (4 <= input_3.value.length) {
input_2.focus();
}
};
};
</script>
<!-- 주문량 확인버튼 -->
<script>
$(document).ready(function() {
$('#checkButton').on('click', function() {
checkOrder();
});
});
function checkOrder(){
const input=Number(prompt('주문량을 입력하세요(짝수로만 주문 가능).','주문량'))
alert(input)
switch(input%2){ //나머지 연산자를 사용하여 홀수와 짝수를 구분
case 0:
const inputConfirm=confirm('주문가능합니다. 주문하시겠습니까?')
if (inputConfirm) {alert('주문 확인되었습니다.')}
else{alert('주문이 취소되었습니다.')}
break
case 1:
alert('주문불가합니다.')
break
default: //위에있는 조건이 아닐때
alert('숫자가 아닙니다. 다시 입력해주세요')
break
}}
</script>
<script>
$(document).ready(function(){
$('#priceButton').on('click',function(){
checkPrice();
});
});
function checkPrice(){
const rawInput=prompt('단체주문할인! 2500원! 주문 수량을 입력해주세요')
const groupOrder= Number(rawInput)
const groupPrice= groupOrder*2500
//출력합니다.
alert(`단체도시락 ${groupOrder}개는 ${groupPrice}원 입니다.`) };
</script>
<style>
/* 슬라이더*/
div.item:nth-child(1){background-color: lightyellow;border-radius: 5px;}
div.item:nth-child(2){background-color: pink;border-radius: 5px;}
div.item:nth-child(3){background-color: lightskyblue;border-radius: 5px;}
/*전체가운데정렬*/
body {width: 960px;
margin: 10px auto}
/*각 id 배경설정*/
#ad {height: 500px; width:200px; background-color:#ff9999; border-radius: 10px; position:fixed; top:10px; right:10px; }
#header {height: 70px; background: lightpink; border-radius: 20px 20px; margin: 10px;padding:20px;font-size: 50px; font-weight: bold;}
#nav {height: 50px; width:360px;border-radius: 20px 20px;margin: 10px auto; padding:20px; overflow: hidden; position:relative;}
#article1 {width:300px; float:left; left: 140px; margin: 10px auto; padding:10px; background: lightseagreen; border-radius: 20px 20px; position:relative;}
#article2 {width:300px; float:right; right: 150px; margin: 10px auto; padding:10px; height:200px; background: lightyellow; border-radius: 20px 20px; position:relative;}
#article3 {width:300px; float:right; right: 140px;margin: 10px auto; padding:20px; height:210px; background: lightsalmon;border-radius: 20px 20px; position:relative;}
#article4 {clear: both; width:500px; left: 130px; margin: 10px auto; padding:20px; height:580px; background: lightcoral;border-radius: 20px 20px;}
#footer {background: lightgrey;border-radius: 20px 20px;margin:10px; padding:20px; }
/*각 id 정렬*/
* {text-align: center;}
/* nav */
div.item{display:flex; width: 50px; margin: 0 auto; padding: 10px; }
#menu1{left: 30px; top:10px; position:absolute; }
#menu2{left: 130px; top:10px; position:absolute;}
#menu3{left: 230px; top:10px; position:absolute;}
#menu4{left: 330px; top:10px; position:absolute;}
/* div에서도 자손 순서대로하면 색상 다르게 할 수 있을것같음 확인!! id가 다 다르게 설정되어있음 ! */
#nav {background-color: rgba(135, 206, 250,0.5)}
#nav:hover{background-color: rgb(135, 206, 250) ;}
div.clear{clear: both;}
.menu {width: 100px; height: 100px;
background-color: red;
margin: 10px; padding: 10px; float: right}
/*표 위치 고정용*/
#menuboard{position:absolute;left: 20px;}
#price{position:absolute; left: 80px;}
#select{position:absolute; left:750px;}
#address{position: absolute; left: 720px;}
</style>
<script>
//팝업
let start= new Date().getTime();
let count= 0;
while (start+100>new Date().getTime()){count++;}
if(count%2==0){
alert('@@@@@행문의 이벤트@@@@@'+ '\n'+ '\n'+ '\n'+ '축하합니다!'+'\n'+'\n'+'\n'+'\n'+count+'원 당첨');}
else{alert('@@@@@행문의 이벤트@@@@@'+ '\n'+'\n'+'\n'+'\n'+count+'번째 꽝');}
//현재시각 표시하기
window.onload=function(){let clock=document.getElementById('clock');setInterval(function(){let now=new Date();clock.innerHTML=now.toString();},1000);
// 제출버튼 만들기
let button=document.getElementById('send'); button.onclick=function(){alert('제출되었습니다.');};
}
</script>
</head>
<body>
<p id='clock'>현재시각</p>
<div id="ad"><p><광고></p>
<p> 광고문의 000-0000-0000</p>
</div>
<div id="header">
<h1>도시락</h1>
</div>
<div data-role="slider" data-width="500" data-height="300">
<div class="container">
<div class="item">
</div>
<div class="item">
</div>
<div class="item">
</div>
</div>
</div>
<button id="left-button"> ⇐</button>
<button id="right-button"> ⇒</button>
<div id="nav">
<div class="item"></div>
<div id="menu1"><h3><a href="#article1">메뉴목록</a></h3></div>
<div id="menu2"><h3><a href="#article2">메뉴판</a></h3></div>
<div id="menu3"><h3><a href="#article3">요금안내</a></h3></div>
<div id="menu4"><h3><a href="#article4">신청</a></h3></div>
</div>
<div class="clear"></div>
<div id="article1">
<h2> <메뉴목록> </h2>
<div class="menu1">
<b>아침</b>: 빵
<br>
</div>
<div class="memu2">
<b>점심</b>: 밥<br>
</div>
<div class="memu3">
<b>저녁</b>: 죽<br>
</div>
</div>
<div id="article2">
<h2><메뉴판></h2>
<div id="menuboard">
<table border="1";>
<tr>
<th></th>
<th><b>월요일</b></th>
<th><b>화요일</b></th>
<th><b>수요일</b></th>
<th><b>목요일</b></th>
<th><b>금요일</b></th>
</tr>
<tr>
<th><b>아침</b></th>
<td>빵1</td>
<td>빵2</td>
<td>빵3</td>
<td>빵4</td>
<td>빵5</td>
</tr>
<tr>
<th><b>점심</b></th>
<td>밥1</td>
<td>밥2</td>
<td>밥3</td>
<td>밥4</td>
<td>밥5</td>
</tr>
<tr>
<th><b>저녁</b></th>
<td>죽1</td>
<td>죽2</td>
<td>죽3</td>
<td>죽4</td>
<td>죽5</td>
</tr>
</table>
</div>
</div>
<div id="article3">
<h2><요금안내></h2>
<div id="price">
<table border="1">
<tr>
<th></th>
<th> 월</th>
<th> 화</th>
<th> 수</th>
<th> 목</th>
<th> 금</th>
</tr>
<tr>
<th>아침</th>
<th colspan="5"> 3500
</th>
</tr>
<tr>
<th>점심</th>
<th rowspan="2"> 5000
</th>
<th colspan="3"> 4000</th>
<th> 4500</th>
</tr>
<tr>
<th>저녁</th>
<th colspan="4">2000</th>
</tr>
</table></div>
</div>
<div>
<div id="article4">
<h2><신청></h2>
<br>
<label for="username"><b>*이름</b></label>
<input id="username" type="text" name="username">
<br>
<p> <b>*성별</b>
<input id="man" type="radio" name="gender" value="m">
<label for="man">남자</label>
<input id="woman" type="radio" name="gender" value="w">
<label for="woman">여자</label>
</p>
<p> <b>*번호</b></p>
<input type="text" class="phone" maxlength="3">
<span>-</span>
<input type="text" class="phone" maxlength="4">
<span>-</span>
<input type="text" class="phone" maxlength="4">
<p><b>*메뉴선택</b></p>
<div id="select">
<table border="1">
<tr>
<th></th>
<th><b>월요일</b></th>
<th><b>화요일</b></th>
<th><b>수요일</b></th>
<th><b>목요일</b></th>
<th><b>금요일</b></th>
</tr>
<!-- checkbox 가 div 안에 있으면 체크가 안됨!! -->
<tr>
<th><b>아침</b></th>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
</tr>
<tr>
<th><b>점심</b></th>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
</tr>
<tr>
<th><b>저녁</b></th>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
<td>
<input type="checkbox"><br>
</td>
</tr>
</table>
</div>
<!-- 체크박스랑 주소랑 겹쳐서 br로 밀어둠. 수정해야함!!!!!!!!!!! -->
<div id="address">
<td> <br><br><br><br><br><br><br><b>*주소</b></td>
<table>
<tr>
<td>
<select>
<optgroup label="서울">
<option>강남구</option>
<option>서초구</option>
<option>강동구</option>
<option>마포구</option>
<option>강서구</option>
</optgroup>
<optgroup label="경기">
<option>성남시</option>
<option>용인시</option>
<option>고양시</option>
<option>하남시</option>
<option>안산시</option>
</optgroup>
</select>
</td>
<td> <select>
<option>주소1</option>
<option>주소2</option>
<option>주소3</option>
<option>주소4</option>
<option>주소5</option>
<option>주소6</option>
<option>주소7</option>
</select></td>
<td> <select>
<option>상세주소1</option>
<option>상세주소2</option>
<option>상세주소3</option>
<option>상세주소4</option>
<option>상세주소5</option>
<option>상세주소6</option>
<option>상세주소7</option>
</select></td>
<td>
<form>
<input type="text">
</form>
</td>
</tr>
</table>
<p><b>*요청사항</b></p>
<form>
<textarea>요청사항을 입력해주세요.</textarea>
</form>
<button id="checkButton">주문가능여부 확인</button>
<button id="priceButton">단체주문 가격확인</button>
<div id="send"> <button type="button" class="btn btn-outline-secondary" value='alert';>제출하기</button></div>
</div>
</div>
<div id="footer">
<p><b> 오시는길</b><address>서울시 금천구 가산디지털1로 70</address></p>
<p><b>번호</b> </p>
<p>000-0000-0000</p>
</div>
</body>
</html>