Is there any way to get query string from url with python code in Web Views?
For example I’ve got this URL
/product?item_code=ABCDEF
And I want to get the url with python code in back end.
Thanks.
Is there any way to get query string from url with python code in Web Views?
For example I’ve got this URL
/product?item_code=ABCDEF
And I want to get the url with python code in back end.
Thanks.
try this
function getQueryParams(qs) {
qs = qs.split('+').join(' ');
var params = {},
tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
return params;
}
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, " "));
}
frappe.ready(function() {
// bind events here
frappe.call({
method: "path.to.your.python",
args: {
"rfq_code":getParameterByName("textinput",window.location.href)
},
callback: function (r, rt) {
if (r.message) {
}
}
});
})
Thank you for the answer but I can do it on javascript, I have this code. I was asking with python. Is there any way?
my method is you do it in javascript and pass it to your python/backend
frappe.call({
method: "path.to.your.python",
args: {
"rfq_code":getParameterByName("textinput",window.location.href)
},
callback: function (r, rt) {
if (r.message) {
}
}
});
Also, can your use case so we can understand better
use
frappe.form_dict
`[quote=“johnskywalker, post:5, topic:31852, full:true”]
Also, can your use case so we can understand better
[/quote]
In a web view, you need the full url to use in your .py. Unless there’s a workaround