By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,689 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,689 IT Pros & Developers. It's quick & easy.

Problem Passing value form popup window to parent window without refresh the parent

P: 6
I require to appear the Name which i click on the "new.php" page in the "Window_open.php" page..I use some Java Script also to accomplish this but I couldn't..

Could you pleas Help ...!!!

Expand|Select|Wrap|Line Numbers
  1. ----------The Code in "Window_open.php" -------------------
  2.  
  3. <html>
  4.  
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  7. <title>New Page 1</title>
  8. </head>
  9.  
  10. <body>
  11.  
  12.  
  13. <FORM>
  14. <INPUT type="button" value="New Window!" onClick="window.open('new.htm','mywindow','width=400,height=200')">
  15. <br>
  16. </FORM> 
  17.  
  18. <table width="533" height="242" border="1">
  19.   <tr>
  20.     <td align="center" valign="middle">Name<br><?php echo $post["txt"]?></td>
  21.   </tr>
  22. </table>
  23. </body>
  24.  
  25. </html>
  26.  
  27.  
  28. ------------------code in "new.php"---------------------------------
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <p><font size="5">This is the result of&nbsp; on click Opening 
  5. Window..............</font><br>
  6. <br>
  7. <br>
  8. <a id="100" onClick="window.close(),pass(100)">Taniya Moses<br></a>
  9. <a id="101" onClick="window.close(),pass(101)">Ranjan Ramanayaka<br></a>
  10. <a id="102" onClick="window.close(),pass(102)">Wikram Silva<br></a>
  11. <a id="103" onClick="window.close(),pass(103)">Wikram Silva<br></a>
  12. <a id="104" onClick="window.close(),pass(104)">Janaka Wujerathna<br></a>
  13. <br>
  14.  
  15.  
  16. <Script type="text/javascript">
  17. function pass(I)
  18. {
  19. var C = document.getElementById("I").value;
  20. document.getElementById("txt").value = C;
  21. window.location.href="new.html";
  22. //window.close();
  23. }
  24. </Script>
  25. </p>
  26. <form action="window_open.html", method="post">
  27. <input type="hidden" id="txt" name="txt"  />
  28. </form>
  29.  
  30. </body>
  31.  
  32. </html>
Attached Files
File Type: zip Lahiru778_Pages.zip (1.0 KB, 285 views)
Aug 16 '09 #1
Share this Question
Share on Google+
12 Replies


gits
Expert Mod 5K+
P: 5,387
could you please explain your requirement a bit better ... step by step ... so that it is more clear what you want to achieve?

kind regards
Aug 16 '09 #2

P: 6
-Attach containing 2 pages
01).window_open.php
02).new.php

Window_open.php is the main page and new .php is the popup window of Windows_open.php

[Please Download the attachment and run the Window_Open.php]

-Click on the bottom and then appear the list of name in the popup window..

Requirment:-
I require to display the name which appear in the popup window("new.php") in the main page (window_open.php), when click on a name of the opoup window.



Example:- Run the window_open.php and click on the button. "in side the popup window there is a list of name appearing..Click on a name..

The name should be appear in the main window by closing the popup window...
Attached Files
File Type: zip Lahiru778_Pages.zip (1.0 KB, 125 views)
Aug 16 '09 #3

gits
Expert Mod 5K+
P: 5,387
threads merged ... please don't double post your questions and keep all things that are related to a specific problem in one thread.

MOD
Aug 16 '09 #4

gits
Expert Mod 5K+
P: 5,387
to your problem ... when you need to pass a value from a child window to the parent window then you might make use of the child window's opener property ... which refers to the parent window.

kind regards
Aug 16 '09 #5

P: 6
There is some small miss in my Syntax..Because of that the code is not working..Can you please go through the Syntax in child window("new.php") and correct it for me ..
I really appreaciate if you can....
Aug 16 '09 #6

gits
Expert Mod 5K+
P: 5,387
do you need it to be posted to your opener php-page or just have it in the opener window. you current code looks more like you want to have it posted to the server ... but i cannot see a submit?
Aug 17 '09 #7

P: 6
What I want is
Copy the folder in to Appachi server and run
(please change the new.htm to new.php in the "Window_Open.php" & "New.php" page code.)[Mistakenly i have put .html inside the syntax]
run
http://localhost:6060/Lahiru778_Pages/Window_Open.php

In that window Click on the "New Window Button" -----------> Child window popping up with list of names -----------> When you click on a name that name should be appear in the Parent Page by closing the pop up window.

Problem--->
The pop up window(new.php) already closing but the Name is not passing to the parent page ("Window_Open.php") from the Child window (new.php)
Aug 17 '09 #8

gits
Expert Mod 5K+
P: 5,387
i will not install any sources and test php code at my side, this is the javascript forum and i could help you with that, to get you on track ... so since you basicly didn't answer my question and just insist to have your code tested and reviewed without saying what really should happen ... i GUESS now that you want to close the popup and want to have a value set to a node in your parent page? ... here is a simple example for how this could be achieved:

Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2.  
  3. <head>
  4. <script type="text/javascript">
  5.  
  6. function openWindow() {
  7.     var win = window.open('', 'mywindow', 'width=400,height=200');
  8.     win.document.body.innerHTML = [
  9.         '<a id="100"',
  10.         'onclick="opener.setName(\'foobar\');',
  11.         'window.close();>Taniya Moses<br></a>'
  12.     ].join('');
  13. }
  14.  
  15. function setName(val) {
  16.     document.getElementById('nameVar').innerHTML = val;
  17. }
  18.  
  19. </script>
  20. </head>
  21. <body>
  22.     <div id="foo" onclick="openWindow();">click here to open window</div>
  23.     <br/><br/>
  24.     <div id="nameVar">no name present</div>
  25. </body>
  26. </html>
  27.  
as you see this code makes use of the opener that refers to the parent window and calls a method that is defined there already. there are several ways to get that to work and the shown one above is just a simple example. so in case you just need it in the window then you could do it that way ... when you need it in a php-page then you need to post it to it.
Aug 17 '09 #9

P: 6
Here I attached a word document by clearly mentioning about my requirement...
please refer the doc. You will able to get the clear idea about exactly what I want.

I try with AJAX but still I couldn't find the correct code that work this done.

If you can do this I really Appreciated ............
Attached Files
File Type: zip Problem in passing values.zip (5.2 KB, 110 views)
Aug 24 '09 #10

gits
Expert Mod 5K+
P: 5,387
threads merged again ... DON'T post the same questions twice or triple times ... keep everything that is related to one question in ONE thread ...

MOD
Aug 24 '09 #11

gits
Expert Mod 5K+
P: 5,387
to the problem ... your requirement was already clear ... and a possible solution was shown in a previous post ... show what you have tried so far. nobody will do a complete solution for you ... since that is not the intention of this forum.

regards
Aug 24 '09 #12

P: 6
Ok Thanks...Thank you very much my friend
Aug 24 '09 #13

Post your reply

Sign in to post your reply or Sign up for a free account.