IT Community - Software Programming, Web Development and Technical Support

How do I retrieve the values from the URL?

This is a discussion on How do I retrieve the values from the URL? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all.... How do I retrieve the values from the URL? Thanks & Regards Pvinoth....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 09-13-2007, 05:03 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default How do I retrieve the values from the URL?

Hi all....

How do I retrieve the values from the URL?

Thanks & Regards
Pvinoth.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-13-2007, 06:30 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Default Re: How do I retrieve the values from the URL?

Hi Vinoth...


here is the sample code...

Quote:
<html>
<head>
<!-- head stuff -->
<script type="text/javascript">
<!-- hide from old browsers

function getValue(varname)
{
// First, we load the URL into a variable
var url = window.location.href;

// Next, split the url by the ?
var qparts = url.split("?");

// Check that there is a querystring, return "" if not
if (qparts.length == 0)
{
return "";
}

// Then find the querystring, everything after the ?
var query = qparts[1];

// Split the query string into variables (separates by &s)
var vars = query.split("&");

// Initialize the value with "" as default
var value = "";

// Iterate through vars, checking each one for varname
for (i=0;i<vars.length;i++)
{
// Split the variable by =, which splits name and value
var parts = vars[i].split("=");

// Check if the correct variable
if (parts[0] == varname)
{
// Load value into variable
value = parts[1];

// End the loop
break;
}
}

// Convert escape code
value = unescape(value);

// Convert "+"s to " "s
value.replace(/\+/g," ");

// Return the value
return value;
}

// end hide -->
</script>
</head>
<body>
<h1>Hello,
<script type="text/javascript">
<!-- hide
var name = getValue("name");
document.write(name);
// end hide -->
</script>
</h1>
</body>
</html>
thnx...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/html-css-javascript-coding-techniques/3809-how-do-i-retrieve-values-url.html
Posted By For Type Date
How to get values from querystring? - DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 11-21-2007 10:36 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve only the Nth row from a table? santhakumar Database Support 6 11-14-2008 05:12 AM
How to Retrieve a Cookie Value? sundarraja PHP Programming 4 04-02-2008 07:00 AM
which method to use so that last inserted value can be retrieve. KiruthikaSambandam Database Support 1 08-07-2007 12:13 AM
How to Store and Retrieve the values in server side caches in ASP.NET? oxygen ASP and ASP.NET Programming 1 07-23-2007 01:14 AM
Store and Retrieve the values in cookies in ASP.NET oxygen ASP and ASP.NET Programming 0 07-20-2007 12:23 AM


All times are GMT -7. The time now is 11:51 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0