Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <head>
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
- <script src="https://code.jquery.com/jquery-3.4.1.js" integrity=”sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=” crossorigin=”anonymous”></script>
- <meta charset="UTF-8">
- <title>ใบแลกของรางวัล</title>
- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"><meta http-equiv="Pragma" content="no-cache">
- </head>
- </head>
- <body>
- <script>
- function clamp(value, min=0.0, max=500000.0) {
- return Math.min(Math.max(value, min), max);
- }
- function formatNumber(n, p, ts, dp) {
- var t = [];
- // Get arguments, set defaults
- if (typeof p == 'undefined') p = 2;
- if (typeof ts == 'undefined') ts = ',';
- if (typeof dp == 'undefined') dp = '.';
- // Get number and decimal part of n
- n = Number(n).toFixed(p).split('.');
- // Add thousands separator and decimal point (if requied):
- for (var iLen = n[0].length, i = iLen? iLen % 3 || 3 : 0, j = 0; i <= iLen; i+=3) {
- t.push(n[0].substring(j, i));
- j = i;
- }
- // Insert separators and return result
- return t.join(ts) + (n[1]? dp + n[1] : '');
- }
- function cheknum(o){
- if (typeof o == "number"){
- return o
- }
- else
- {
- return 0
- }
- }
- function calsum(){
- var a = cheknum(parseFloat(document.getElementById("redeem_a").textContent));
- var b = cheknum(parseFloat(document.getElementById("redeem_b").textContent));
- var c = cheknum(parseFloat(document.getElementById("redeem_c").textContent));
- var z = a+b+c;
- document.getElementById("totredeem").placeholder = formatNumber(z,2);
- }
- function recal_funca() {
- var x = clamp(document.getElementById("qty_a").value);
- var y = document.getElementById('point_a').textContent;
- var z = parseFloat(x)*parseFloat(y)
- document.getElementById("redeem_a").innerHTML = formatNumber(x*y,2);
- calsum();
- }
- function recal_funcb() {
- var x = clamp(document.getElementById("qty_b").value);
- var y = document.getElementById('point_b').textContent;
- var z = parseFloat(x)*parseFloat(y)
- document.getElementById("redeem_b").innerHTML = formatNumber(x*y,2);
- calsum();
- }
- function recal_funcc() {
- var x = clamp(document.getElementById("qty_c").value);
- var y = document.getElementById('point_c').textContent;
- var z = parseFloat(x)*parseFloat(y)
- document.getElementById("redeem_c").innerHTML = formatNumber(x*y,2);
- calsum();
- }
- </script>
- <div class="container" style="width: 38rem;" align="center">
- <img src="127.0.0.1/banner.jpg" style='height: 100%; width: 100%; object-fit: contain'>
- </div>
- <form id="newForm">
- <div class = 'container' align="center">
- <h2 id='Display' class = 'text-danger'>แลกคะแนนสะสม สำหรับลูกค้าV1.0</h2>
- </div>
- <div class="container">
- <!-- Customer Header -->
- <div class="row">
- <div class="col-sm">
- <label id='lcustcode'><h5>รหัสลูกค้า</h5></label>
- </div>
- <div class="col-sm">
- <input class="form-control input-sm" style="high=:30px;width:150px;margin-bottom:0px"
- type="text" id="txtcustcode" name="custcode" value=C-X0001>
- </div>
- <div class="col-sm">
- <label id='lcustname'><h5>ชื่อ ลูกค้า </h5></label>
- </div>
- <div class="col-sm">
- <input class="form-control input-sm" style="high=:30px;width:700px;margin-bottom:0px"
- type="text" id="txtcustname" name="custcode" value=Mario>
- </div>
- </div>
- </div>
- <!-- table header maybe problem -->
- <div class="container">
- <div class="row">
- <div class="col-sm">
- <label id='hcol1'>รหัส</label><br>
- </div>
- <div class="col-sm">
- <label id='hcol2'>รายการ</label>
- </div>
- <div class="col-sm">
- <label id='hcol3'>จำนวนชิ้น</label>
- </div>
- <div class="col-sm">
- <label id='hcol4'>อัตราแลก</label>
- </div>
- <div class="col-sm">
- <label align = 'right' id='hcol5'>รวม Point</label>
- </div>
- </div>
- <!-- table body -->
- <div class="row">
- <div class="col-sm">
- <label id='code_a'>DD0018-A</label><br>
- </div>
- <div class="col-sm">
- <label id='desc_a'>ป้ายทองคำ 2 บาท</label>
- </div>
- <div class="col-sm">
- <input class="form-control input-sm" style="high=:30px;width:80px;margin-bottom:0px"
- type="number" id="qty_a" name="qty_a" value =0 onchange="recal_funca()">
- </div>
- <div class="col-sm">
- <label id='point_a'>20</label>
- </div>
- <div class="col-sm">
- <p align='right' id='redeem_a'>0.00</p>
- </div>
- </div>
- <div class="row">
- <div class="col-sm">
- <label id='code_b'>DD0018-B</label><br>
- </div>
- <div class="col-sm">
- <label id='desc_b'>ป้ายทองคำ 1 บาท</label>
- </div>
- <div class="col-sm">
- <input class="form-control input-sm" style="high=:30px;width:80px;margin-bottom:0px"
- type="number" id="qty_b" name="qty_b" value=0 onchange="recal_funcb()">
- </div>
- <div class="col-sm">
- <label id='point_b'>16</label>
- </div>
- <div class="col-sm">
- <p align='right' id='redeem_b'>0.00</p>
- </div>
- </div>
- <div class="row">
- <div class="col-sm">
- <label id='code_c'>DD0018-C</label><br>
- </div>
- <div class="col-sm">
- <label id='desc_c'>ป้ายทองคำ 0.5 บาท</label>
- </div>
- <div class="col-sm">
- <input class="form-control input-sm" style="high=:30px;width:80px;margin-bottom:0px"
- type="number" id="qty_c" name="qty_c" value=0 onchange="recal_funcc()">
- </div>
- <div class="col-sm">
- <label id='point_c'>12</label>
- </div>
- <div class="col-sm">
- <p align='right' id='redeem_c'>0.00</p>
- </div>
- </div>
- <div class="row">
- <div class="col-sm" align = 'right'>
- <h4>
- <label id='desctot'>รวมยอดการแลก : </label>
- <br>
- <input align='right' id='totredeem' class="text-sm-end"
- type="text" placeholder="0.00" readonly>
- <br>
- <label>Point(s)</label>
- </h4>
- </div>
- </div>
- <div class="row">
- <div class="col-sm">
- <button id='mybtnsubmit' type="button" class="btn btn-info"
- style="high=:20px;width:100%;margin-bottom:1px">Submit</button>
- </div>
- <div class="col-sm">
- <button id='btnclr' type="button" class="btn btn-warning"
- style="high=:20px;width:100%;margin-bottom:1px">Reset</button>
- </div>
- </div>
- </form>
- <script>
- document.getElementById("mybtnsubmit").addEventListener("click", nfunc);
- document.getElementById("btnclr").addEventListener("click", clearvalue);
- </script>
- <script>
- function nfunc(){
- alert('click here');
- }
- function clearvalue(){
- alert('clear here');
- document.getElementById("newForm").reset();
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement