-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
23 lines (18 loc) · 827 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let imageContainer = document.getElementById('imgContainer');
let imgSrc = document.getElementById('imgSrc');
let myinput = document.getElementById('myinput');
let messageElement = document.getElementById('message');
function generateQr() {
let inputValue = myinput.value.trim();
//If input is not empty
if (inputValue !== "") {
imgSrc.src = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + inputValue;
imageContainer.classList.add("max-h-96", "border", "border-solid");//Adding the styling
// Display the message
messageElement.classList.remove("hidden");
} else {
alert("You need to write something first !!!");
// Hide the message if no QR code is generated
messageElement.classList.add("hidden");
}
}