ระบบ random ตัวเลข
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Dev Examblog | |
//https://examblog64.krooluang.com/ | |
//https://www.youtube.com/@ExamBlog | |
function doGet() { | |
return HtmlService.createTemplateFromFile("index").evaluate() | |
.setTitle("WebAppRandomnumber") | |
.addMetaTag('viewport', 'width=device-width, initial-scale=1') | |
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>RandomNumber</title> | |
<script src="https://code.jquery.com/jquery-3.6.4.js"></script> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" /> | |
<!-- Bootstrap CSS --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> | |
<style> | |
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai&display=swap'); | |
* { | |
font-family: 'Noto Sans Thai', sans-serif; | |
} | |
.color { | |
color: #000; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container mt-5"> | |
<div class="col-md-4 mx-auto card shadow border border-3 border-primary rounded text-center"> | |
<div class="fs-2 bg-primary p-2 text-white">RandomNumber</div> | |
<div class="card-body "> | |
<div id="number" style="display:none" class="fs-1 fw-bolder text-center my-3 color"></div> | |
<div id="exnumber" class="fs-1 text-center my-3 color">0</div> | |
<button type="button" onclick="random()" class="btn btn-primary">Random</button> | |
</div> | |
</div> | |
<div class="copyright fixed-bottom"></div> | |
</div> | |
<script> | |
$(document).ready(()=>{ | |
setFooter() | |
color() | |
}); | |
function random(){ | |
document.getElementById('number').style.display = "block"; | |
document.getElementById('exnumber').style.display = "none"; | |
document.getElementById("number").innerHTML = | |
Math.floor(Math.random() * 100); | |
color() | |
} | |
function color() { | |
var colors = ["#6610f2", | |
"#dc3545", | |
"#d63384", | |
"#0d6efd", | |
"#1C8200", | |
"#950dea", | |
"#f40de6", | |
"#b0510c", | |
"#1987FC", | |
"#99081E"]; | |
var bodybgarrayno = Math.floor(Math.random() * colors.length); | |
var selectedcolor = colors[bodybgarrayno]; | |
$(".color").css("color",selectedcolor); | |
} | |
</script> | |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/gh/examblog/web/js/FtExamblog.js"></script> | |
</body> | |
</html> |