Skip to content

Instantly share code, notes, and snippets.

@krooluang
Created August 17, 2023 08:54
Show Gist options
  • Save krooluang/a48efc3ac11bf19da47be701078d1a8a to your computer and use it in GitHub Desktop.
Save krooluang/a48efc3ac11bf19da47be701078d1a8a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<base target="_top">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.6.4.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<style>
@import url('https://fonts.googleapis.com/css2?family=Sarabun&display=swap');
body {
font-family: 'Sarabun', sans-serif;
font-size: .875rem;
}
a {
color: #198754;
text-decoration: none;
}
</style>
</head>
<body>
<div class="container mb-5">
<div class="col-md-6 mx-auto">
<div class="h5 bg-success text-white p-2 mb-2"><i class="fa-solid fa-align-justify"></i> Form Generator QRCODE</div>
<form id="myForm" onsubmit="submitForm(this)">
<label><i class="fa-brands fa-chrome"></i> กรอก link ที่ต้องการสร้าง QRCODE</label>
<input type='url' class="form-control mb-2" id='chl' placeholder="ตัวอย่าง https://examblog.com" pattern="https://.*" required>
<button type="submit" class="btn btn-success w-100" id="btn1" ><i class="fa-solid fa-qrcode"></i> สร้าง QRCODE</button>
</form>
<div class="text-center">
<div id="qrcode"></div>
</div>
</div>
</div>
<footer class="text-center fixed-bottom mb-4">
<div class="copyright"></div>
</footer>
<script>
$(document).ready(function() {
setFooter()
});
function submitForm(obj){
event.preventDefault()
var chs = $('#chs').val()
var chl = $('#chl').val()
var qr = "https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl="+chl+""
$("#qrcode").html(`<a href="${qr}" target="_blank"><img src="${qr}" width="60%"></a>`)
$('#myForm')[0].reset()
}
</script>
<script src="https://cdn.jsdelivr.net/gh/examblog/web/js/FtExamblog.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment