QRCode to Webpage

Good Day

I have a barcode with a QR Code on it and would like to create a new webpage with route : item.
My QR Code will have the following: http://myurl.co.za/item?serialnumber for instance.

I would like to know if it would be possible to:

get specific serial number info from serial numbers from erpnext and display info on item webpage?

Could this be done with javascript? or how should i do this?

Thank You

Albertus Geyser

1 Like

Good Day

I used the folowing javascript to get serial number from QR Code:

function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[[]]/g, “\$&”);
var regex = new RegExp("[?&]" + name + “(=([^&#]*)|&|#|$)”),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return ‘’;
return decodeURIComponent(results[2].replace(/+/g, " "));
}

var item = getParameterByName(‘sr’);
document.getElementById(“sr”).innerHTML = item;

With following html:

Item

With QR Code url:

http://myurl.co.za/item?sr=201700001

Any idea how can i get serial info from erpnext with javascript or any other way?

Thank You

Albertus Geyser

Good Day

I have the following:

function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[[]]/g, “\$&”);
var regex = new RegExp("[?&]" + name + “(=([^&#]*)|&|#|$)”),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return ‘’;
return decodeURIComponent(results[2].replace(/+/g, " "));
}

var item = getParameterByName(‘sr’);
document.getElementById(“sr”).innerHTML = item;

$.ajax({
url: ‘api/method/login’,
method: ‘POST’,
data: { usr: “user@domain”, pwd: “password”},
dataType: “json”,
success: function(resdata) {
$("#one").html(“Success”);
},
error: function(resdata, errorThrown){
$("#one").html(“Failed”);
}
});

$.ajax({
url: ‘api/resource/Serial No/’ + item,
method: ‘GET’,
dataType: “json”,
success: function(data) {
$("#two").html(“Success”);
},
complete: function(data){
alert(data.description);
alert(data.owner);
},
error: function(resdata, errorThrown){
$("#two").html(“Failed”);
}
});

This Fails to get serial number data is sais undefined, but if i use JSON.stringify(data), then i can see all json data.

Can anyone help?

Thank You

Albertus Geyser