QR Code Generator

QR Code Generator




Instructions

In this code, we have an input field where the user can enter the text or URL for which they want to generate a QR code. There is also a "Generate QR Code" button, which triggers the generateQRCode() function when clicked.

Inside the generateQRCode() function, we retrieve the input value and check if it's not empty. If it's not empty, we create a new QRCode object and pass the input value as the text parameter. We also specify the desired width and height of the QR code (200px in this example). The QR code is then rendered inside the <div id="qr-code"></div> element.

To generate the QR code, we utilize the qrcode.min.js library by David Shim. It's included in the code using the <script> tag with the src attribute pointing to the CDN link.

Feel free to copy and use this code to create your own QR code generator.