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  
Old 09-13-2007, 04:03 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 235
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
  #2  
Old 09-13-2007, 05:30 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 278
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 Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve only the Nth row from a table? santhakumar Database Support 6 11-14-2008 04:12 AM
How to Retrieve a Cookie Value? sundarraja PHP Programming 4 04-02-2008 06:00 AM
Retrieve mails from server kingmaker C# Programming 6 12-14-2007 10:42 PM
How to Store and Retrieve the values in server side caches in ASP.NET? oxygen ASP and ASP.NET Programming 1 07-23-2007 12:14 AM
Store and Retrieve the values in cookies in ASP.NET oxygen ASP and ASP.NET Programming 0 07-19-2007 11:23 PM


All times are GMT -7. The time now is 06:29 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0