...

View Full Version : Grabbing value from URL



TrainReq
12-22-2006, 11:14 PM
Right now... i have it to where it grabs the value username by putting in a div.
(For example if i do <div name="John" id="name" style="display:none;">) it will make the value for username John .... i did that by doing this line of javascript:

function getusername(){var name_div=document.getElementById('name');if(name_div){var username=name_div.getAttribute('name');if(username)return username;}var i,j,h,s;h=document.location.href;s='usrn=';i=h.indexOf(s);if(i==-1)return '';i+=s.length;j=h.indexOf('&',i);if(j==-1)return '';return h.substring(i,j);}




What will i have to change in that code to get username from the URL by going for example http://site.com/file.html?name=John (with file.html having the javascript on it) or http://site.com/file.html?name=Bob ... (wich will make the value for getusername Bob)

More/less , i would like to do ?name=USERNAME in a URL instead of having to do <div name="USERNAMEHERE" id="name" style="display:none;">

TrainReq
12-23-2006, 01:58 AM
bump

-



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum