0
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 someone help me?
0
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 someone help me?
-1
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.
Remembering that I need not only print the value but also the name.
Are you talking about something like "[email protected]" return "email: [email protected]"? In this case you would have to add something like var mobile = "variableVindaURL " + getUrlParameter('mobile'); ?
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.
See if you can get help http://answall.com/questions/134065/qual-express%C3%A3o-regular-para-tratrar-uma-url/134078#134078
– MagicHat