passing values from child pop up window to parent window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeddsal
    New Member
    • Dec 2011
    • 8

    passing values from child pop up window to parent window

    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(someho w 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.

    Code:
    //this is my code for my form.php:
    
    <html>
    <head> <title> </title>
    <script src="../javascript/list.js"> </script>
    </head>
    <body>
    <form action="" name="addcashadv" method="post">
    
    <table class="mytable" align="center">
    <tr><th colspan="3"></th></tr>
    	
    	<h2 align="center"> Add Cash Advance </h2>
    	<tr>
    		<td>Check Number:</td>
    		<td>
    			<input type="text" name="chekno" value="" /> 
    			<input type="button" onClick="List()" value="List of Checks">
    		</td>
    	</tr>	
    	
    	<tr>
    		<td>Employee Id:</td>
    		<td>
    			<input type="text" name="empid" onClick="" value="" />
    		</td>
    	</tr>
    	<tr>
    		<td>Full Name:</td>
    		<td>
    			<input type="text" name="fullname" value="" />
    		</td>
    	</tr>
    	<tr>
    		<td>Travel Order No:</td>
    		<td>
    			<input type="text" name="travelorder_no" value="" />
    			
    			
    		</td>
    	</tr>
    	
    	<tr>
    		<td>Remarks:</td>
    		<td>
    			<textarea name="Cashadvremarks"></textarea>
    		</td>
    	</tr>
    	
    	<tr>
    		<td></td>
    		<td>
    			<input type="submit" name="Submit" value="Submit" /> <input type="reset" value="Reset">
    			
    		</td>
    	</tr>
    	</table>
    
    </form>
    </body>
    </html>
    Code:
    //this is my code for the viewchecks.php
    
    <html>
    <head>
    <title></title>
    <link rel="stylesheet" a href="stylesheets/style.css" type="text/css"/> 
    </head>
    <body>
    
    
    <?php
    
    include "classes/pgsql_db.class.php";
    include "classes/checks_class.php";
    
    $conn = new pgsql_db();
    $checks = new checks($conn);
    
    
    
    
    $sort_select_array = array("Check No.", "Check Date", "Amount", "Payee");
    
    
      
    
    $cdata = $checks->getChecks(); # get_results
    
    
    
    ?>
    
    <h2>Checks</h2>
    
    
    <table id="checksTable" table border="1" cellpadding = "3" class="mytable_data">
    <?php include "layouts/table_header.php"; ?> 
    
    <?php 
    if(!empty($cdata)){
    foreach($cdata as $data)
    {
    echo "
    
    </tr>
    <td width='70'>".$data->checkno."</td>
    <td width='110'>".$data->checkdate."</td>
    <td width='100'>"."P ".$data->amount."</td>
    <td width='400'>".$data->payee."</td>
    </tr>";
    } 
    }else{
    echo "<p class='error italic'>There are no checks.</p>";
    }
    
    
    ?>
    </table>
    
    
    </body>
    </html>

    Code:
    //and this is my code for my JavaScript for pop-up 
    
    function List() {
    			window.open( "viewchecks.php", "myWindow", 
    			"status = 1, height = 600, width = 800, resizable = 0" )
    			}
    can anybody pls help???i would really appreciate it.
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    #2
    hi use the following method which i know do far
    main file which opens popup window
    file name = main.html
    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=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function popup(b_id){
    				window.open("popup.html","Popup","height=700,width=525,,scrollbars=yes,"+ 
    						"directories=yes,location=yes,menubar=yes," + 
    						 "resizable=yes status=yes,history=yes top = 50 left = 100");
    			}
    
    </script>
    </head>
    
    <body>
    <a href="#." onclick="popup();">Popu up</a>
    <form name="myform" id="myform">
    	<input type="text" name="passed_value" id="passed_value" />
    </form>
    </body>
    </html>
    code for popup window

    file name = popup.html

    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=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function closeit(val){
    	window.opener.document.forms['myform'].elements['passed_value'].value=val;
    	window.close(this);
    }
    
    </script>
    </head>
    
    <body>
    hi this is a popup screen please clik here to close<a href="#." onclick="closeit('5');">close</a>
    </body>
    </html>
    hope it helps ,
    regards,
    Omer Aslam

    Comment

    • jeddsal
      New Member
      • Dec 2011
      • 8

      #3
      thanks so much....i was really able to apply it to my code

      Comment

      • omerbutt
        Contributor
        • Nov 2006
        • 638

        #4
        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

        Comment

        Working...