2주차 수업 숙제

판매 페이지 환율 API 표시

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
        integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
        integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
        crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
        integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
        crossorigin="anonymous"></script>

    <title>스파르타코딩클럽 | 부트스트랩 연습하기</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nanum+Pen+Script&family=Noto+Serif+KR:wght@200&family=Sunflower:wght@300&display=swap" rel="stylesheet">
</head>


<style>
    * {
        font-family: font-family: 'Nanum Pen Script', cursive;
        font-family: 'Noto Serif KR', serif;
        font-family: 'Sunflower', sans-serif;;
    }
    .image {
        width: 500px;
        height: 400px;

        background-image: url("http://m.flatpoint.co.kr/web/product/big/201703/158_shop1_628142.jpg");
        background-size: cover;
        background-position: center;
    }

    .wrap {
        width: 500px;
        margin: auto;
    }
    .coin {
        width: 500px;
        margin-top: 20px;
        margin-bottom: 20px;
        font-size: 20px;
    }
    .order {
        width: 500px;
        margin: auto;
    }
    .btn-order{
        margin: auto;
        width: 100px;
        display: block;
    }
    .rate{
        color: blue;
    }
</style>

<script>
    $(document).ready(function () {
        get_rate();
    });

    function get_rate() {
        $.ajax({
            type: "GET",
            url: "http://spartacodingclub.shop/sparta_api/rate",
            data: {},
            success: function (response) {
                let now_rate = response['rate'];
                $('#now-rate').text(now_rate);
            }
        })
    }

    function order() {
        alert('주문 완료~!');
    }
</script>

<body>
<div>
    <div class="wrap">
        <div class="image"></div>
        <div class="text">
            <h1>접시를 판매합니다.
                <span class="coin">가격:20,000원/세트</span></h1>
            <p>다양한 사이즈의 접시들을 세트로 구매하실 수 있어요.</p>
            <p class="rate">달러-원 환율: <span id="now-rate">1219.15</span></p>
        </div>
    </div>
</div>
<div class="order">
    <div class="input-group mb-3">
        <div class="input-group-prepend">
            <span class="input-group-text">주문자이름</span>
        </div>
        <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default">
    </div>
    <div class="input-group mb-3">
        <div class="input-group-prepend">
            <label class="input-group-text" for="inputGroupSelect01">수량</label>
        </div>
        <select class="custom-select" id="inputGroupSelect01">
            <option selected>-- 수량을 선택하세요 --</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
        </select>
    </div>
    <div class="input-group mb-3">
        <div class="input-group-prepend">
            <span class="input-group-text">주소</span>
        </div>
        <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default">
    </div>
    <div class="input-group mb-3">
        <div class="input-group-prepend">
            <span class="input-group-text">전화번호</span>
        </div>
        <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default">
    </div>
    <button type="button" onclick="order()" class="btn btn-primary btn-order">주문하기</button>
</div>

</body>

</html>

좋은 웹페이지 즐겨찾기