I found some old code on Internet for this idea, I tried refactoring it and fixing it, but I can't make it work.
HTML:
<script src="https://cdn.rawgit.com/amanuel/JS-HTML5-QRCode-Generator/master/qrcode.js"></script>
<script src="https://cdn.rawgit.com/amanuel/JS-HTML5-QRCode-Generator/master/html5-qrcode.js"></script>
<h1>WiFi</h1>
<form id="form">
<label><span>SSID:</span><input id="ssid" placeholder="SSID"></label>
<label><span>Password:</span><input id="password" placeholder="Password"></label>
<label>
<span>Encryption:</span>
<select id="enc">
<option>WPA</option>
<option>WEP</option>
</select>
</label>
<label><span>Is Hidden?</span><input type="checkbox" id="hidden"></label>
<button id="print" onclick="window.print()">Print</button>
</form>
<div id="qrcode">
<img>
</div>
Javascript:
function updateQRCode() {
var ssid = document.getElementById("ssid").value;
var pw = document.getElementById("password").value;
var enc = document.getElementById("enc").value;
var hidden = document.getElementById("hidden").checked;
var qrcode = document.getElementById("qrcode");
var text = "WIFI:S:" + ssid + ";T:" + enc + ";P:" + pw + ";H:" + hidden + ";;";
qrcode.replaceChild(showQRCode(text), qrcode.lastChild);
}
document.getElementById("form").onchange = updateQRCode;
I'm a junior developer, so any help is very much appreciated, to help me kickstart this project