control new window

H

Hiep Nguyen

Hello, i'm looking for a javascript solution to the following problem:

I have two pages: list.php and update.php

on list.php page, i have a hyperlink to update.php page (open a new window). when user click update button on update.php, i want to update mysql table, automatically close update.php page and refresh list.php page.

anyone got any suggestion for this. thank you so much.

t. hiep
 
D

Doug Gunnoe

Hello, i'm looking for a javascript solution to the following problem:

I have two pages: list.php and update.php

on list.php page, i have a hyperlink to update.php page (open a new window).  when user click update button on update.php, i want to update mysql table, automatically close update.php page and refresh list.php page.

anyone got any suggestion for this.  thank you so much.

t. hiep

In the child window, or what have you, you can reference the parent
window as "opener".

In one such app I had a child window with a map to select points.
After the user clicked submit, I called a function written in the
parent window like so:

opener.yourFunction(params);

Then I did window.close();

Actually here is a snip I had in the child window:

function sendMapData(){
if(piCoordDOM && toCoordDOM){
stuff
}
else{

opener.setOnMap(piCoordDOM.value,toCoordDOM.value,map.getZoom());
window.close();
}
}
else
stuff
}

And here is a snip I had in the parent document

function setOnMap(pipoint, topoint, zoom){
stuff
}
 
D

Doug Gunnoe

And you also need to check to make sure the opener has not been closed
by the user.

Maybe if(window.opener) But not 100% sure about that last part.
 
H

Hiep Nguyen

Hello, i'm looking for a javascript solution to the following problem:

I have two pages: list.php and update.php

on list.php page, i have a hyperlink to update.php page (open a new
window). when user click update button on update.php, i want to update
mysql table, automatically close update.php page and refresh list.php
page.

anyone got any suggestion for this. thank you so much.

t. hiep

In the child window, or what have you, you can reference the parent
window as "opener".

In one such app I had a child window with a map to select points.
After the user clicked submit, I called a function written in the
parent window like so:

opener.yourFunction(params);

Then I did window.close();

Actually here is a snip I had in the child window:

function sendMapData(){
if(piCoordDOM && toCoordDOM){
stuff
}
else{

opener.setOnMap(piCoordDOM.value,toCoordDOM.value,map.getZoom());
window.close();
}
}
else
stuff
}

And here is a snip I had in the parent document

function setOnMap(pipoint, topoint, zoom){
stuff
}

i'm clueless on what you explained. i'm a newbie to java. thanks.

t. hiep
 
D

Doug Gunnoe

i'm clueless on what you explained.  i'm a newbie to java.  thanks.


Ok. Well it is Javascript not to be confused with java. However, it is
really not all that complicated.

I assume that your update.php is like a pop up window.

The following demonstrates a little of what you are looking for. It
should put you on the right path.

In the parent window (list.php for you)

<html>
<head>
<script>
function doStuff(msg){
alert("here is a message from the child window: " + msg);
}
</script>
</head>

<body>

<input type="button" value="click me"
onclick="window.open('kiddoc.html','kidwin','width=300,height=300')" /

</body>

</html>

In the child window which I named kiddoc.html, (but is update.php in
your case)

<html>
<head>
<script>

function sendStuff(){
window.opener.doStuff('hi there');
window.close();
}


</script>
</head>

</body>
</html>

You can cut and paste this into two docs on your desktop, just name
the child window kiddoc.html, and this will work.

Good luck.
 
M

My Pet Programmer

Hiep Nguyen said:
[snip]
i'm clueless on what you explained. i'm a newbie to java. thanks.

t. hiep
Trouble is, that's the answer. Here you go:
http://tinyurl.com/2hdc3e
That -^ is a link to a google search for "window.opener". Have fun.

~A!

--
Anthony Levensalor
(e-mail address removed)

Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. - Albert Einstein
 
H

Hiep Nguyen

Doug Gunnoe said:
i'm clueless on what you explained. i'm a newbie to java. thanks.

t. hiep


Ok. Well it is Javascript not to be confused with java. However, it is
really not all that complicated.

I assume that your update.php is like a pop up window.

The following demonstrates a little of what you are looking for. It
should put you on the right path.

In the parent window (list.php for you)

<html>
<head>
<script>
function doStuff(msg){
alert("here is a message from the child window: " + msg);
}
</script>
</head>

<body>

<input type="button" value="click me"
onclick="window.open('kiddoc.html','kidwin','width=300,height=300')" /

</body>

</html>

In the child window which I named kiddoc.html, (but is update.php in
your case)

<html>
<head>
<script>

function sendStuff(){
window.opener.doStuff('hi there');
window.close();
}


</script>
</head>

</body>
</html>

You can cut and paste this into two docs on your desktop, just name
the child window kiddoc.html, and this will work.

Good luck.

thanks. i'll give it a try.
t. hiep
 
H

Hiep Nguyen

Hiep Nguyen said:
Ok. Well it is Javascript not to be confused with java. However, it is
really not all that complicated.

I assume that your update.php is like a pop up window.

The following demonstrates a little of what you are looking for. It
should put you on the right path.

In the parent window (list.php for you)

<html>
<head>
<script>
function doStuff(msg){
alert("here is a message from the child window: " + msg);
}
</script>
</head>

<body>

<input type="button" value="click me"
onclick="window.open('kiddoc.html','kidwin','width=300,height=300')" /
 
H

Hiep Nguyen

Hiep Nguyen said:
Ok. Well it is Javascript not to be confused with java. However, it is
really not all that complicated.

I assume that your update.php is like a pop up window.

The following demonstrates a little of what you are looking for. It
should put you on the right path.

In the parent window (list.php for you)

<html>
<head>
<script>
function doStuff(msg){
alert("here is a message from the child window: " + msg);
}
</script>
</head>

<body>

<input type="button" value="click me"
onclick="window.open('kiddoc.html','kidwin','width=300,height=300')" /


</body>

</html>

In the child window which I named kiddoc.html, (but is update.php in
your case)

<html>
<head>
<script>

function sendStuff(){
window.opener.doStuff('hi there');
window.close();
}


</script>
</head>


</body>
</html>

You can cut and paste this into two docs on your desktop, just name
the child window kiddoc.html, and this will work.

Good luck.

thanks. i'll give it a try.
t. hiep
i got it works now, but i need to refresh list.php page right before
window.close().
I tried window.opener.reload(true), but it doesn't work. any idea how to
refresh the parent window before window.close(). thanks.
 
H

Hiep Nguyen

Doug Gunnoe said:
i'm clueless on what you explained. i'm a newbie to java. thanks.

t. hiep


Ok. Well it is Javascript not to be confused with java. However, it is
really not all that complicated.

I assume that your update.php is like a pop up window.

The following demonstrates a little of what you are looking for. It
should put you on the right path.

In the parent window (list.php for you)

<html>
<head>
<script>
function doStuff(msg){
alert("here is a message from the child window: " + msg);
}
</script>
</head>

<body>

<input type="button" value="click me"
onclick="window.open('kiddoc.html','kidwin','width=300,height=300')" /

</body>

</html>

In the child window which I named kiddoc.html, (but is update.php in
your case)

<html>
<head>
<script>

function sendStuff(){
window.opener.doStuff('hi there');
window.close();
}


</script>
</head>

</body>
</html>

You can cut and paste this into two docs on your desktop, just name
the child window kiddoc.html, and this will work.

Good luck.


i think i know the problem. how do i force list.php reload after update.php
page updated mysql table? in other word, after user clicked update button
on update.php page, this page will update the record in mysql table then
reload list.php page. is this possible at all? or do i need to find a
different way to update my table???

thanks
 
D

Doug Gunnoe

i think i know the problem. how do i force list.php reload after update.php
page updated mysql table? in other word, after user clicked update button
on update.php page, this page will update the record in mysql table then
reload list.php page. is this possible at all? or do i need to find a
different way to update my table???

thanks

I see trouble with this, however you can try

window.location.href=window.location.href.

I think what I would do is arrange things so that I could submit the
form from list.php instead of the pop up window.

Maybe something like this, and I'm shooting from the hip here, so take
this with a grain of salt:

Lets say save the input from the pop up window to the values of a
hidden form on your list.php, then when you close the pop up window,
do document.yourHiddenForm.submit (from list.php) where yourHiddenForm
is the name of your hidden form, of course, and then the action
attribute of the form I suppose would be "list.php".

Also, from what you have said, it sounds like you need to update part
of a page, maybe take a look at AJAX.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top