Solved

Retrieve Query String parameters

Posted on 2011-09-05
3
323 Views
Last Modified: 2012-06-22
How can I retrieve query string parameters from my javascript code?

If possible, please provide some sample code.
Thanks!
0
Comment
Question by:dshrenik
3 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 125 total points
ID: 36486368
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 36486415
If you meant the Current URL query string parameters, then you just have to do

var queryString = location.search;

var keyPairsCombined = queryString.split("&");
var keyPairMap = new Array();

for ( var counter = 0; counter < keyPairsCombined.length; counter++)
{
   var keyPair = keyPairsCombined[ counter ].split("=");
   keyPairMap[ keyPair[ 0 ] ] = keyPair[ 1 ];
}

now just mention the name like
alert(keyPairMap.name);
0
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 125 total points
ID: 36486504
This link has number of ways to extract the query strings

http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now