Generate QR code using jQuery

Introduction: Hello Guys, “Welcome back” Today i am here with another one new great article. In this article I will explain about how to generate QR code using jQuery.

Code for HTML Page

On the HTML page there will be two controls one is text box Control with the id named text_qrcode for to enter the input by the user and other control is Button with the id named button_submit. On the Button click I assigned a JavaScript  function named QR_code() to the onclick event handler.

<input id="txt_qrcode" type="text" />

<input type="button" id="btn_submit" onclick="QR_code()" />

<div id="qrcode" class="" style=" padding: 10px;height:auto;width:65px;"></div>

When user will click on the Submit button then JavaScript function named QR_code() will be called.

jQuery Implementation

First, the jQuery files jquery-1.8.2.js as well as qrcode.min.js is inherited

 for to implement QR Code. Also created a JavaScript function named 

QR_code. I will call JavaScript function on the click of Submit Button. 

When user will enter the Button after entering the input inside the 

textbox then QR Code will be automatically generated for the entered Text.

<script type="text/javascript">

    function QR_code()

{

 

var QR= document.getElementById(“txt_qrcode”).value;

 

var qrcode = new QRCode

(

  "qrcode",

  {

    text: QR, // you can set your QR code text

    width: 100,

    height: 100,

    colorDark : "#000000",

    colorLight : "#FFFFFF",

    correctLevel : QRCode.CorrectLevel.M

  }

);

Here i am giving the complete HTML code for HTML page. You can copy and paste 

this code to your HTML page to enjoy the execution of the Article.

<!DOCTYPE html>
<html>
<head>
<title>How to generate QR code using jquery</title>
<script src="https://code.jquery.com/jquery-1.8.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/
libs/qrcodejs/1.0.0/qrcode.min.js">
</script>
</head>
<body>
<h4>How to generate QR code using jquery 
<a href="https://usingaspdotnet.blogspot.com">Demo</a></h4>
<!-- Here i set the  id="qrcode" to the  div tag -->
 
<div id="qrcode" style="padding: 10px;height:auto;width:65px;"></div>
 
<input type="text" id="txt_qrcode" />
 
<input type="button" id="btn_Submit" value="Submit"  
onclick="QR_code()" />
<script type="text/javascript">
 function QR_code() 
{
 
var QR= document.getElementById("txt_qrcode").value;
 
var qrcode = new QRCode
(
  "qrcode",
  {
    text: QR, // you can set your QR code text
    width: 100,
    height: 100,
    colorDark : "#000000",
    colorLight : "#FFFFFF",
    correctLevel : QRCode.CorrectLevel.M
  }
);
}
</script>
</body>
 </html> 
Conclusion: In above code, I have been explained that how to generate QR code using 
jQuery. This code is very helpful for every developer. Bye Bye and take care of yourself 
Developers. We will comeback shortly with the new article.

Regards

Using Asp.net

 

 

Comments

Popular posts from this blog

Sending reset password link for one time use only in asp.net

add delete update inside gridview using store procedure in ASP.NET

Change password using asp.net