Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 22nd, 2006, 9:41 AM   #1
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
popup problem...

I have a popup window which has some text boxes and sends them back to the parent page.However when I submit,new page is being loaded in the popup.I want to close that window and see the answers in the main window.I can do this but I couldnt see the information on my parent page just as I hit submit,though I see the information in the new page which is loaded in the popup.
P.S. I even tried to reload the parent page but it didnt work.I used this
print("<input type=\"submit\" value=\"SUBMIT\" onClick=\"window.opener.location.reload();window.close();\">");

thanx...
guess is offline   Reply With Quote
Old Feb 22nd, 2006, 11:00 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I can't tell exactly what you mean, but you can use opener.focus () to focus on the parent prior to doing the child.close (). When you do the submit from the child, the response will come back to the child. If that's what you want, fine, then transfer any appropriate material in the response back to the parent and close the child. If you want the response to come back to the parent, transfer the information from the child to the parent (hidden fields, if you like), trigger a parent submit, focus on the parent, and close the child.

If all this is nonsense, you'll have to be clearer on what you want and how you are failing to achieve it.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 23rd, 2006, 1:52 AM   #3
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
I understand you.But I have already sent the variables by post method back to the parent.But the information goes to the window which is opened by the child.I mean child submits the information to the parent,but the information sent can only be seen from the child window.But I want to see it on the parent when I close the child.I hope U can understand and help me...
guess is offline   Reply With Quote
Old Feb 23rd, 2006, 6:02 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You need to learn to express your needs clearly. You also need to learn not to PM me for solutions. That subverts the purpose of the forum, which is to serve people as a community, with shared solutions. It also subverts my purpose, which is to offer help and time without charge, but without being expected to respond on demand.

Now, I'm going to express what I THINK you want. You confirm or deny. If it's correct, I will provide you with a solution.

1. I want to gather information in a child window.
2. I want to submit the information to the server from the child window.
3. I understand that the server will respond to the child window.
4. I want to transfer the information from the child window to the parent window.
5. I want to close the child window and switch focus back to the parent.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 23rd, 2006, 6:30 AM   #5
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
U exactly got my point.Im waiting for ur solution.
guess is offline   Reply With Quote
Old Feb 23rd, 2006, 9:39 AM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
This is the parent window code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Fetch from Server Via Child</title>
<script type="text/javascript">
var myKey = "";
var myValue = "";
var myChild;
function popWin (URL, features)
{
	var f = "width=400,height=300,top=30,left=30," +
	  		"screenx=30,screeny=30," +
			"resizable=yes,scrollbars=no";	
	document.getElementById ("key").value = "";
	document.getElementById ("val").value = "";
	if (features) f = features;
	Win = open (URL, "popWindow", f);
	Win.focus ();
	return Win;
}
</script>
</head>
<body style="font-size: larger;">
<div align="center">
There is a file on the server with two key:value pairs.<br />
They are Guess:Who and DaWei:Bubba.<br />
Click the button below to collect and submit a keyword and fetch the appropriate value.
<br/><br />
</div>
Your current keyword is: <input type="text" id="key" name="key" value="" />
The matching value is: <input type="text" id="val" name="val" value="" />
<input name="collect" type="button" value="Collect" 
	onclick="myChild=popWin ('collect.php');"/>
</div>
</body>
</html>
This is the child window code:
<?php
$found = "false";
$first = "true";
if ($_GET)
{
	$first = "false";
	$key = $_GET ['key'];
	$lines = file ("kvFile.txt");
	foreach ($lines as $line)
	{
		$pair = explode (',', $line);
		if (trim ($pair [0]) == $key)
		{
			$value = trim ($pair [1]);
			$found = "true";
			break;
		}
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Collect</title>
<script type="text/javascript">
var first = <?php echo '"'.$first.'";';?>
var found = <?php echo '"'.$found.'";';?>
var key = <?php echo '"'.$key.'";';?>
var value = <?php echo '"'.$value.'";';?>
var parent = window.opener;
function passBack ()
{
	kObj = parent.document.getElementById ("key");
	vObj = parent.document.getElementById ("val");
	kObj.value = key;
	vObj.value = value;
	parent.focus ();
	window.close ();
}
</script>
</head>
<body>
<script type="text/javascript">
if (found == "true") passBack (); else  if (first == "false") alert ("Not Found");
</script>
<form action="collect.php" method="get">
Enter your keyword: <input type="text" name="key" id="key" value="" />
</form>
</body>
</html>
You may see this in action here
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 24th, 2006, 2:14 AM   #7
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
thanx dawei,but more help plz...

1-)Thank u for the code.But I already knew how to do this.I wanted to know How I could get them with post or get method.Because Im going to write a query in order to get information from the database on the parent page.
2-)What I didnt tell u is,just as I close the popup,I must append something on the parent page.When I use document.write method,it deletes all of the text on the parent and writes something which I put in the document.write.
Well I may use document.append method,however I searched from google and I couldnt find the syntax.

If u help me in those 2 problems,I think I will be able to go on my project...
guess is offline   Reply With Quote
Old Feb 24th, 2006, 2:52 AM   #8
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
Man its ok.I found the syntax.Thank u for everything.If I get stuck in another place.Im gonna ask u for ur help.Thanx a lot again...
guess is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:29 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC