I need to read all the values of a URL (below) in Javascript, taking both the name and the value to store in a database.
cadastro.php?codigo=4355&nome=Renan&[email protected]&celular=66992541453&40=on&11=on
Can anyone help me?
I need to read all the values of a URL (below) in Javascript, taking both the name and the value to store in a database.
cadastro.php?codigo=4355&nome=Renan&[email protected]&celular=66992541453&40=on&11=on
Can anyone help me?
You can try something like this function below, and then use the variables at the end of the code.
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
}
var mobile = getUrlParameter('mobile');
var index = getUrlParameter('index');
var table = getUrlParameter('table');
I hope it works.