Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 25th, 2003, 09:45 PM
Authorized User
 
Join Date: Oct 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default return previous file after a window is closed

when i clicked the radio button in salesreport.php, a new window is open to let the user choose the category to view (act as a prompt box with list box). when the ok button is clicked, the user will return to the salesreport.php to make the rest of the things he needed to choose. My question is :
1. how to return to the previous salesreport.php when the ok button is clicked on the chosecat.php.
2. if the cancel button is clicked how am i going to return to the previous salesreport.php
because i need the user to go back to the salesreport.php to continue enter other data.

//salesreport.php
<input type="radio" name="view_by" value="specategory"
onclick="window.open('chosecat.php', 'mywindow', 'height=100, width=400')">View Specified Category<br>

//chosecat.php
//i think the problem is here in the action
<form name="catform" method=POST action="salesreport.php"> Please select the category name below <br><br>
<?php
$query = " SELECT CAT_NAME FROM CATEGORY ORDER BY CAT_NAME";
$result = mysql_query ($query);
if(!$result) error_message (sql_error());
while($row = mysql_fetch_array($result))
{
    $CAT_NAME[ ] = $row["CAT_NAME"];
}
echo "<select name=\"viewhighcat\">";
for($i=0; $i<=7; $i++)
    {
        echo "<option>$CAT_NAME[$i] </option>";
    }
echo "</select>";
?>
<input id="but1" type="submit" name="catsubmit" value="OK">
<input id="but2" type="button" name="btncancel" value="CANCEL" >

 
Old December 27th, 2003, 09:34 AM
Authorized User
 
Join Date: Oct 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i found answer to my 2 question by <input id="but2" type="button" name="btncancel" value="CANCEL" onclicked="self.close()>

but i didn't know what to do When the user clicked the ok button. how can i pass the value entered in the list box to the salesreport.php and go the previous salesreport.php page that open the chosecat.php?
i try to do it this way <form name="myform" method="get" action="salesreport.php"> but a new salesreport.php is opened.

 
Old January 1st, 2004, 02:13 AM
Authorized User
 
Join Date: Oct 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the problem is solved. Here's the code.

// salesreport.html
<form name="myform">
<input type="radio" name="view_by" value="overall">Overall<br>
<input type="radio" name="view_by" value="category">View Category<br>
<input type="radio" name="view_by" value="specategory" onclick="window.open('chosecat.html', 'mywindow', 'height=100, width=400')">View Specified Category<br>
<input type="text" name="text1" value="name">
</form>

// chosecat.html
<script type="text/javascript">
function function1()
{
opener.document.myform.text1.value = document.myform2.specat.options[document.myform2.specat.selectedIndex].value;
}
</script>

<form name="myform2">
<select name="specat">
<option value="category1">category1</option>
<option value="category2">category2</option>
<option value="category3">category3</option>
<option value="category4">category4</option>
<option value="category5">category5</option>
</select>
<input id="but1" type="button" name="catsubmit" value="OK" onclick="function1();self.close()">
<input id="but2" type="button" name="btncancel" value="CANCEL" onclick="self.close()">
</form>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing all child window when browser is closed h@ckerz ASP.NET 2.0 Professional 1 July 17th, 2008 01:04 AM
closed parent window when opened child window jaiwin Javascript How-To 0 October 8th, 2006 12:54 PM
how to destroy session when window is closed chayanvinayak PHP How-To 1 June 1st, 2006 06:18 AM
Determining how a window is closed chrscote Javascript How-To 2 June 16th, 2005 07:53 AM
why does this over write the previous file starsailor Pro JSP 0 December 6th, 2004 03:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.