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

passing values from child pop up window to parent window

P: 8
can anyone help me, i have a php form and i have a view form which contains data in a table from the database.
what i am trying to do is that when i click the "List of Checks button" beside the text box check no. a pop up window will be displayed containing the data from the database(somehow i already managed to do that)

what i can't do is that i want to pass the value of the selected check no to be passed to the parent form in the check no text box.

it will be like the values of the check no column can be clicked and when the user selects a particular check no it will be passed to the original form and the pop up window will be closed.

can anyone help me.

Expand|Select|Wrap|Line Numbers
  1. //this is my code for my form.php:
  2.  
  3. <html>
  4. <head> <title> </title>
  5. <script src="../javascript/list.js"> </script>
  6. </head>
  7. <body>
  8. <form action="" name="addcashadv" method="post">
  9.  
  10. <table class="mytable" align="center">
  11. <tr><th colspan="3"></th></tr>
  12.  
  13.     <h2 align="center"> Add Cash Advance </h2>
  14.     <tr>
  15.         <td>Check Number:</td>
  16.         <td>
  17.             <input type="text" name="chekno" value="" /> 
  18.             <input type="button" onClick="List()" value="List of Checks">
  19.         </td>
  20.     </tr>    
  21.  
  22.     <tr>
  23.         <td>Employee Id:</td>
  24.         <td>
  25.             <input type="text" name="empid" onClick="" value="" />
  26.         </td>
  27.     </tr>
  28.     <tr>
  29.         <td>Full Name:</td>
  30.         <td>
  31.             <input type="text" name="fullname" value="" />
  32.         </td>
  33.     </tr>
  34.     <tr>
  35.         <td>Travel Order No:</td>
  36.         <td>
  37.             <input type="text" name="travelorder_no" value="" />
  38.  
  39.  
  40.         </td>
  41.     </tr>
  42.  
  43.     <tr>
  44.         <td>Remarks:</td>
  45.         <td>
  46.             <textarea name="Cashadvremarks"></textarea>
  47.         </td>
  48.     </tr>
  49.  
  50.     <tr>
  51.         <td></td>
  52.         <td>
  53.             <input type="submit" name="Submit" value="Submit" /> <input type="reset" value="Reset">
  54.  
  55.         </td>
  56.     </tr>
  57.     </table>
  58.  
  59. </form>
  60. </body>
  61. </html>
  62.  
Expand|Select|Wrap|Line Numbers
  1. //this is my code for the viewchecks.php
  2.  
  3. <html>
  4. <head>
  5. <title></title>
  6. <link rel="stylesheet" a href="stylesheets/style.css" type="text/css"/> 
  7. </head>
  8. <body>
  9.  
  10.  
  11. <?php
  12.  
  13. include "classes/pgsql_db.class.php";
  14. include "classes/checks_class.php";
  15.  
  16. $conn = new pgsql_db();
  17. $checks = new checks($conn);
  18.  
  19.  
  20.  
  21.  
  22. $sort_select_array = array("Check No.", "Check Date", "Amount", "Payee");
  23.  
  24.  
  25.  
  26.  
  27. $cdata = $checks->getChecks(); # get_results
  28.  
  29.  
  30.  
  31. ?>
  32.  
  33. <h2>Checks</h2>
  34.  
  35.  
  36. <table id="checksTable" table border="1" cellpadding = "3" class="mytable_data">
  37. <?php include "layouts/table_header.php"; ?> 
  38.  
  39. <?php 
  40. if(!empty($cdata)){
  41. foreach($cdata as $data)
  42. {
  43. echo "
  44.  
  45. </tr>
  46. <td width='70'>".$data->checkno."</td>
  47. <td width='110'>".$data->checkdate."</td>
  48. <td width='100'>"."P ".$data->amount."</td>
  49. <td width='400'>".$data->payee."</td>
  50. </tr>";
  51. }else{
  52. echo "<p class='error italic'>There are no checks.</p>";
  53. }
  54.  
  55.  
  56. ?>
  57. </table>
  58.  
  59.  
  60. </body>
  61. </html>
  62.  

Expand|Select|Wrap|Line Numbers
  1. //and this is my code for my JavaScript for pop-up 
  2.  
  3. function List() {
  4.             window.open( "viewchecks.php", "myWindow", 
  5.             "status = 1, height = 600, width = 800, resizable = 0" )
  6.             }
  7.  
  8.  
can anybody pls help???i would really appreciate it.
Dec 5 '11 #1

✓ answered by omerbutt

hi use the following method which i know do far
main file which opens popup window
file name = main.html
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <script type="text/javascript">
  7. function popup(b_id){
  8.                 window.open("popup.html","Popup","height=700,width=525,,scrollbars=yes,"+ 
  9.                         "directories=yes,location=yes,menubar=yes," + 
  10.                          "resizable=yes status=yes,history=yes top = 50 left = 100");
  11.             }
  12.  
  13. </script>
  14. </head>
  15.  
  16. <body>
  17. <a href="#." onclick="popup();">Popu up</a>
  18. <form name="myform" id="myform">
  19.     <input type="text" name="passed_value" id="passed_value" />
  20. </form>
  21. </body>
  22. </html>
  23.  
  24.  
code for popup window

file name = popup.html

Expand|Select|Wrap|Line Numbers
  1.  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <script type="text/javascript">
  7. function closeit(val){
  8.     window.opener.document.forms['myform'].elements['passed_value'].value=val;
  9.     window.close(this);
  10. }
  11.  
  12. </script>
  13. </head>
  14.  
  15. <body>
  16. hi this is a popup screen please clik here to close<a href="#." onclick="closeit('5');">close</a>
  17. </body>
  18. </html>
  19.  
  20.  
hope it helps ,
regards,
Omer Aslam

Share this Question
Share on Google+
3 Replies


omerbutt
100+
P: 638
hi use the following method which i know do far
main file which opens popup window
file name = main.html
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <script type="text/javascript">
  7. function popup(b_id){
  8.                 window.open("popup.html","Popup","height=700,width=525,,scrollbars=yes,"+ 
  9.                         "directories=yes,location=yes,menubar=yes," + 
  10.                          "resizable=yes status=yes,history=yes top = 50 left = 100");
  11.             }
  12.  
  13. </script>
  14. </head>
  15.  
  16. <body>
  17. <a href="#." onclick="popup();">Popu up</a>
  18. <form name="myform" id="myform">
  19.     <input type="text" name="passed_value" id="passed_value" />
  20. </form>
  21. </body>
  22. </html>
  23.  
  24.  
code for popup window

file name = popup.html

Expand|Select|Wrap|Line Numbers
  1.  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <script type="text/javascript">
  7. function closeit(val){
  8.     window.opener.document.forms['myform'].elements['passed_value'].value=val;
  9.     window.close(this);
  10. }
  11.  
  12. </script>
  13. </head>
  14.  
  15. <body>
  16. hi this is a popup screen please clik here to close<a href="#." onclick="closeit('5');">close</a>
  17. </body>
  18. </html>
  19.  
  20.  
hope it helps ,
regards,
Omer Aslam
Dec 5 '11 #2

P: 8
thanks so much....i was really able to apply it to my code
Dec 6 '11 #3

omerbutt
100+
P: 638
Hi jeddsal
i am glad that it solved your problem , please choose the right answer so that other might also have help
regards,
Omer Aslam
Dec 6 '11 #4

Post your reply

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