/    Sign up×
Community /Pin to ProfileBookmark

problem in getting the values from main page to child window

Hi,

I have to get the value of var ‘y’ into test.html page from main page..so while click on button I have written the,
fun get(){
var y=4;
window.open (“test.html?GETST=”+y,”STModel”);
}

In test.html:

var sample=document.getElementById(“GETST”);
alert(“sam”+sample);
but In alert it’s not displaying the value ‘4’ it’s displaying null..help me out..what I have to add in test.html page?

Thanks a lot…

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@nap0leonDec 27.2007 — AFAIK, stuff in the URL doesn't automatically get loaded into getElementByID.

Here's a JavaScript function that "Gets URL Parameter" copied from http://www.netlobo.com/url_query_string_javascript.html

[CODE]
function gup( name ){
name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
var regexS = "[\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null ) return "";
else return results[1];
}
[/CODE]


try changing your:

var sample = getElementById("GETST");

to:

var sample = gup('GETST');

(and add the gup function)
×

Success!

Help @Reena 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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