Java Coder
How can I get query string values in JavaScript?
1 Answer(s)      a year and 7 months ago
Posted in : Java Beginners

How can I get query string values in JavaScript?

Advertisement
View Answers

December 27, 2013 at 5:44 PM


To get a query string value, you can use JQuery and JavaScript.. here is the code:

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}









Related Tutorials/Questions & Answers:
Advertisements