Hello all.
I am trying to create a page that can create qr codes, it has html and js code
But it loads the html but not the function in js, which generates the code
the html code is:
and the js code is:
I am trying to do this in a b4j file with the BANano library.
but I don't know how to apply the js so that it looks and can be executed
I can only see the input, without any function
thanks for your help, i am something new with this language
source code: https://codepen.io/davidshimjs/pen/NdBYrg
I am trying to create a page that can create qr codes, it has html and js code
But it loads the html but not the function in js, which generates the code
the html code is:
html:
<input id="text" type="text" value="https://hogangnono.com" style="width:80%" /><br />
<div id="qrcode"></div>
and the js code is:
js:
var qrcode = new QRCode("qrcode");
function makeCode () {
var elText = document.getElementById("text");
if (!elText.value) {
alert("Input a text");
elText.focus();
return;
}
qrcode.makeCode(elText.value);
}
makeCode();
$("#text").
on("blur", function () {
makeCode();
}).
on("keydown", function (e) {
if (e.keyCode == 13) {
makeCode();
}
});
I am trying to do this in a b4j file with the BANano library.
but I don't know how to apply the js so that it looks and can be executed
b4j:
Sub Process_Globals
Dim Banano As BANano'ignore
End Sub
'
Sub AppStart
Banano.Header.AddJavascriptFile("jquery.min.js")
Banano.Header.AddJavascriptFile("qrcode.js")
End Sub
Sub Initialize 'ignore
Dim body As BANanoElement = Banano.GetElement("#body")
body.Append($"<input id="text" type="text" value="https://hogangnono.com" style="width:80%" /><br /><div id="qrcode"></div>"$)
Dim container As BANanoElement = body.Append($"<canvas width="100" height="100" style="display: none;"></canvas>"$)
container.SetStyle(Banano.ToJson(CreateMap("margin": 0, "padding": 0)))
Banano.RunJavascriptMethod("makeCode", Array( "QRCode" ) )
End Sub
#If Javascript
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 100,
height : 100,
useSVG: true
});
function makeCode () {
var elText = document.getElementById("text");
if (!elText.value) {
alert("Input a text");
elText.focus();
return;
}
qrcode.makeCode(elText.value);
}
makeCode();
$("#text").
on("blur", function () {
makeCode();
}).
on("keydown", function (e) {
if (e.keyCode == 13) {
makeCode();
}
});
#End If
I can only see the input, without any function
thanks for your help, i am something new with this language
source code: https://codepen.io/davidshimjs/pen/NdBYrg