How can get value from URL in javascript, the parameter is in array what can I do please help me and thanks in advance my code and URL is below:
URL is :
propertyList?address=&sub_type%5B%5D=3&sub_type%5B%5D=6&min_price=
I want sub_type
value, I got other parameter value which are single and not in array with this function :
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
I used this function and got the value of address
and min_price
value but it is not working in sub_type
.
What can I do to get sub_type
value?