File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > QR Code Generator</ title >
7+ < style >
8+ body {
9+ font-family : Arial, sans-serif;
10+ text-align : center;
11+ padding : 50px ;
12+ }
13+ # qrcode {
14+ margin-top : 20px ;
15+ }
16+ input [type = "text" ] {
17+ width : 80% ;
18+ padding : 10px ;
19+ font-size : 16px ;
20+ }
21+ button {
22+ padding : 10px 20px ;
23+ font-size : 16px ;
24+ margin-top : 20px ;
25+ cursor : pointer;
26+ }
27+ </ style >
28+ </ head >
29+ < body >
30+ < h1 > QR Code Generator</ h1 >
31+ < input type ="text " id ="textInput " placeholder ="Enter text or URL " />
32+ < br />
33+ < button onclick ="generateQRCode() "> Generate QR Code</ button >
34+ < div id ="qrcode "> </ div >
35+
36+ <!-- Include the QRCode.js library -->
37+ < script src ="https://cdn.jsdelivr.net/npm/qrcodejs/qrcode.min.js "> </ script >
38+
39+ < script >
40+ // Function to generate the QR code
41+ function generateQRCode ( ) {
42+ // Get the input value
43+ const text = document . getElementById ( 'textInput' ) . value ;
44+
45+ // Clear any previous QR codes
46+ document . getElementById ( 'qrcode' ) . innerHTML = '' ;
47+
48+ // Generate a new QR code
49+ if ( text ) {
50+ new QRCode ( document . getElementById ( 'qrcode' ) , text ) ;
51+ } else {
52+ alert ( "Please enter some text or URL!" ) ;
53+ }
54+ }
55+ </ script >
56+ </ body >
57+ </ html >
You can’t perform that action at this time.
0 commit comments