/    Sign up×
Community /Pin to ProfileBookmark

how can i pass php variable into a javascript pop up window??

i have this code

<script type=”text/javascript”>
function expiredpop() {
window.open( “viewcheck.php”, “myWindow”,
“status = 1, height = 300, width = 300, resizable = 0” )
}
</script>

<a href=”” onclick=”expiredpop()”>MOVE SCHEDULE</a>

views=<?php echo $view=$rows[‘id’]; ?>—where should i place this??

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@cbVisionJun 15.2011 — What is your "views" variable suppose to do?
Copy linkTweet thisAlerts:
@ballballauthorJun 15.2011 — yeap it pass the variables from my database
Copy linkTweet thisAlerts:
@ballballauthorJun 15.2011 — naahh i just fixed it.. thanks for replying ?
Copy linkTweet thisAlerts:
@chrisecclesJun 16.2011 — It may be of greater value to those learning if you were to

demonstrate *how* you solved the problem ! ;-)

Personally, I would change your code to:

[CODE]<script type="text/javascript">
function expiredpop() {
var newWind = window.open( "viewcheck.php", "myWindow",
"status = 1, height = 300, width = 300, resizable = 0" );
}
</script>

<a href="" onclick="expiredpop()">MOVE SCHEDULE</a>
[/CODE]


making sure that "viewcheck.php" actually wrote some HTML

which included text or hidden fields with defined ID's.

then, using:

[CODE]newWind.document.getElementById("someField").value = . . . ;
[/CODE]

your calling page could pass values by ID to the new window or,

by using.:

[CODE]var newVariable = window.opener.document.getElementById("someField").value;
[/CODE]

in the new window, it could acquire values from the main window.

The second method is better.


Chris
×

Success!

Help @ballball 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...