Subscribe to Subscribers
Talk to Webmaster Tony John


Resources » TypeScript » Scripting Languages » Javascript

How to pass Query String value from java script


Posted Date:     Category: Javascript    
Author: Member Level: Gold    Points: 20


In this article I have explained about how to pass Query String value from java script with Example. Each steps I have clearly explained in this article.



 



In this example I'm passing Querystring value to other pages with help of window.open function.
To split the url using split method.



var vquery = window.location.search.substring(1);
alert(vquery);


In First Page:-






<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Passing Query String Values between pages</title>

<script type="text/javascript" language="javascript">
function PassQueryStringValue()
{
var vQueryStringVal = "Welcome";
alert("DisplayQueryString.aspx?Qid=" + vQueryStringVal+"&dotnetspider");
window.open("DisplayQueryString.aspx?Qid=" + vQueryStringVal+"& Qid1=dotnetspider");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PassQueryStringValue();" />
</div>
</form>
</body>
</html>


To get the Query string value we can use GetQueryStringValue



In Second Page:-



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function GetQueryStringValue()
{

var vquery = window.location.search.substring(1);

var vparms = vquery.split('&');

for (var i=0; i <vparms.length; i++)

{

var vpos = vparms[i].indexOf('=');

if (vpos > 0) {

var vkey = vparms[i].substring(0,vpos);

var vval = vparms[i].substring(vpos+1);

alert(vval);

}

}

}

</script>
</head>
<body onload="GetQueryStringValue()">
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>






Did you like this resource? Share it with your friends and show your love!


Responses to "How to pass Query String value from java script"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: How select one radio button from multiple radio button in gridview
    Previous Resource: How to select and unselect checkbox using Java script
    Return to Resources
    Post New Resource
    Category: Javascript


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    How to pass Query String value from java script  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.