/    Sign up×
Community /Pin to ProfileBookmark

calling variable

Hello

I how could I call/ get the value of variable from the following…

[url]http://www.mysite.com/signup.html?refno=12[/url]

I want to call variable… refno how could I do that in javascript?

Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ExuroOct 30.2004 — Try this code:
[code=php]function getParam(paramName) {
var rx = new RegExp("^\?.*"+paramName+"=([^;]+)(;|$)");
var ar = rx.exec(unescape(location.search));
if (ar) {
return ar[1];
}
else {
return null;
}
}
// Set the document's onload function
window.onload = function () {
alert(getParam("a"));
}[/code]

If your query string was [FONT=courier new]"?nums=123four"[/FONT] then [FONT=courier new]getParam("nums")[/FONT] would return [FONT=courier new]"123four"[/FONT]. Anyway, I hope that helps!
Copy linkTweet thisAlerts:
@edpudolauthorOct 30.2004 — Hey.. thanks.. this helps ?
×

Success!

Help @edpudol spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...