Click here to Skip to main content
13,507,742 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 17 Jan 2013

Handling QueryString Using jQuery

, 18 Jan 2013
Rate this:
Please Sign up or sign in to vote.
Handle QueryString Using JQuery


This article will help to handle QueryString values using jQuery.


I was unable to handle designs (select particular options) according to querystring values when the page got refreshed. So I used jQuery to handle these querystring values. After page gets refreshed, Jquery code will execute and help to handle querystring variables easily.

Using the Code

In normal back-end code when page gets refreshed, the default values will be reset to variable. So in my initial code, Jquery worked for default variable. Later, I came across the below code to handle QueryString variable such that after Page get refreshed, Jquery code will be executed and get new querystring values.

Hence jQuery worked for new QueryString values.

<script type="text/javascript" language="javascript">
        var urlParams = {};
        (function () 
            var match,
            pl= /\+/g,  // Regex for replacing addition symbol with a space
            search = /([^&=]+)=?([^&]*)/g,
            decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
            query  =;

            while (match = search.exec(query))
            urlParams[decode(match[1])] = decode(match[2]);
         if( urlParams["q1"]=== 1 )
        { return 1; }
}); </script>

Here... urlParams["q1"], qurlParams["q2"], urlParams["q3"] are the values of querystring variables q1, q2, q3 respectively.

Points of Interest

Front end design becomes easy to handle.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer Sonata Software Pvt Ltd
India India
Hi.. I am Vinod Kumar B C from Mysore, Karnataka. I have done MCA and currently working as a Software Engineer having 3 Years of Experience in web development. I know, C#, MVC, Sql Server, CSS, JQuery, C, C++, HTML, DB2, DataStructures.

You may also be interested in...


Comments and Discussions

Generaljquery Pin
Manohar_manu17-Jan-13 23:57
groupManohar_manu17-Jan-13 23:57 
GeneralRe: jquery Pin
vinodkumarnie18-Jan-13 0:07
membervinodkumarnie18-Jan-13 0:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180417.1 | Last Updated 18 Jan 2013
Article Copyright 2013 by vinodkumarnie
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid