Created
May 3, 2019 15:09
-
-
Save liketaurus/00cb274b28cafd88df07a1c591d51fca to your computer and use it in GitHub Desktop.
How to generate QR-code using JavaScript
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
<div> | |
<input type="text" id="textToQR" /> | |
<button id="GenQR" onclick="makeCode();">Generate QR from text</button> | |
</div> | |
<br> | |
<div id="qrcode" style="width:160px; height:160px; margin-top:15px;"></div> | |
<script src="https://code.jquery.com/jquery-3.4.1.js"></script> | |
<script src="qrcode.min.js"></script> | |
<script> | |
var qrcode = new QRCode("qrcode"); | |
function makeCode () { | |
var elText = $('#textToQR'); | |
if (!elText.val()) { | |
alert("Input a text"); | |
elText.focus(); | |
return; | |
} | |
qrcode.makeCode(elText.val()); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment