Description:

In this article, I will explain how to get Query string values on client side using Jquery.  

As we know, Query string is used to pass values from one page to another page.

Query string will pass the values with the page Url.


The above page Url contains two query string values such as variable1 and variable2.

In the below program, I have used JavaScript function to retrieve the query string values.

The function will get the url by using window.location.search.substring(1) and it will split the url and retrieve the query string values.

Example Program:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
      </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var obj1 = GetQSValues('Variable1');
            var obj2 = GetQSValues('Variable2');
            alert(" Welcome " + obj1 + " " + obj2 + "");
           
            function GetQSValues(Parameters) {
                var UrlofPage = window.location.search.substring(1);
                var SplitUrl = UrlofPage.split('&');
                for (var i = 0; i < SplitUrl.length; i++) {
                    var ParamerterValues = SplitUrl[i].split('=');
                    if (ParamerterValues[0] == Parameters) {
                        return ParamerterValues[1];
                    }
                }
            }
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>


Jquery get Querystring value, Get Querystring with Jquery , Handling Querystring using Jquery, Get Url and Querystring value with Jquery, Get values from Querystring using Jquery Getting Querystring values with Jquery, Find Querystring value using Javascript

0 comments:

Post a Comment

 
Top