If at first youdon't succeed, then give up and try a bulldozer approach: -
Create a seperate php script for the new window.
>From your existing page, open the new window with javascript, passing in the
required id parameter to identify the cart contents that you want to display. If
you can't identify that shoppers contents by a single ID, (or at worst a combo of
a couple of ID's) then you will have to pass all the required parameters as
javascript variables and in the querystring you use to open the new window so that
PHP can find them.

To pass a php value to javascript, try something like: -
Calling funciton: -
<a href=javascript:AddItem($ID)> where $ID is a php variable in your main script
and the jscript function is something like: -

function AddItem(IDent)
 {
 
msgWindow=window.open("AddWindow.php?ID="+IDent,"displayWindow","menubar=no,width=400,height=200")

    }

It's not ideal, but it should get you up and running!

Tom

Bob Sears wrote:

> I am probably driving everyone ballistic, but I am going to get to the
> bottom of this code problem with PHP/Javascript
> because I don't want to rewrite the application in HTML/ASP/Oracle, if at
> all possible.
>
> I want to be able to generate a pop-up window and populate that window with
> a formatted representation of a customer's current shopping cart status. Since
> PHP does not do client-side stuff and Javascript does not do data base I/O,
> I have to use both in concert.
>
> The PHP program in question follows, with the location given by "here is
> the problem code".
>
> Everything is contained in that one program.
>
> Reads the data base and displays the contents of the product data base
> based on selection criteria passed by the preceding program. This function
> works very well. The problem is when the customer clicks on the "View Cart"
> link.
> At that point, I want to have a pop-up screen and populate it with the
> current order status. No where in the Wrox Press "Professional PHP
> Programming"
> text do I find an example.
>
> The module needs to overlay the first panel, thereby preserving all
> pointers into the data base and not destroy or reassign the session
> variables, which is used as the index into the temporary order MySQL table.
> I can
> get the pop-up window to display but it never populates it with the order
> status, which
> is written to a file and pointed to by the Javascript logic. The
> onClick="do the
> Javascript windowing" functions correctly in opening a new window. When I
> change it to onClick="<? do the PHP stuff ?>", the function doesn't work. When
> combining the two to generate the report and open the window ...
> onClick="<? do the PHP stuff ?>; do the Java windowing stuff", I quickly
> receive an error message that halts execution.
>
> Can a combination of PHP and Javascript do what needs to be done or am I
> asking too much of either language and
> what I am asking cannot be accomplished? If it can be accomplished but I am
> doing it incorrectly, what is a correct
> logic flow? This little snag is causing the entire project to be put on
> hold. I would dearly welcome any suggestions.
>
> <?
> function output_order_to_file(){
> .
> .---------------------------------------------------------------------------
> -----------------------------> this PHP generates the cart status report to
> a file
> .
> $theScreen .= "<table width=90% border=0 align=center cellpadding=3>";
> $theScreen .= "";
> $theScreen .= " <tr>";
> $theScreen .= "<td class=largeprint align=center colspan=5 align=center
> bgcolor=#7FFFD4>";
> $theScreen .= "HERE IS YOUR ORDER";
> $theScreen .= "</td>";
> $theScreen .= "</tr>";
> $theScreen .= "<tr>";
> $theScreen .= "<td align=center
> bgcolor=".$headerColor.">INVENTORY<BR>NUMBER</td>";
> $theScreen .= "<td align=center bgcolor=".$headerColor.">DESCRIPTION</td>";
> $theScreen .= "<td align=right bgcolor=".$headerColor.">QUANTITY</td>";
> $theScreen .= "<td align=right bgcolor=".$headerColor.">PRICE</td>";
> $theScreen .= "<td align=right bgcolor=".$headerColor.">SUBTOTAL</td>";
> $theScreen .= "</tr>";
> $grandTotalRetail = 0;
> $grandTotalQty = 0;
> while ($row = mysql_fetch_array($result)){
> $storedDescription = $row['Description'];
> $storedID = $row['Id'];
> $storedRetail = $row['Retail'];
> $storedQty = $row['Qty'];
> settype ($storedRetail, "integer");
> settype ($storedQty, "integer");
> if ($colorSwitch == 0){
> $colorOfTD = $color0;
> $colorSwitch = 1;
> } else {
> $colorOfTD = $color1;
> $colorSwitch = 0;
> }
> .
> .
> .
> $theScreen .= "</tr>";
> $theScreen .= "</table>";
> $theScreen .= "</BODY>";
> $theScreen .= "</HTML>";
>
> ----------------------------------------------------------------------------
> -------------------------------- here is the file i/o
> ----------------------------------------------------------------------------
> -------------------------------- but the logic never enters this paragraph
> $filename = "temporderfile.html";
> $fd = fopen ($filename, "w");
> fwrite ($fd, $theScreen);
> fclose ($fd);
> }
> //--------------------------------------------------------------------------
> --------
> //--------------------------- end of generating report of the shopping cart
> contents
> //--------------------------------------------------------------------------
> --------
>
> .
> .
> .
> .
> session_start();
> //session_register("rnumber");
> if (!IsSet($rnumber)){
> $mtime = explode (" ",microtime());
> $mseconds = $mtime[0] * 1000000000;
> srand($mseconds);
> $rnumber = rand();
> session_register("rnumber");
> }
> .
> .
> .
> $db_name = "frogpond";
> $table_name = "product";
> $connection = mysql_connect ("localhost","","") or
> die ("Couldn't connect to localhost");
> $db = mysql_select_db ($db_name, $connection) or
> die ("Couldn't select $db_name");
> parse_str($QUERY_STRING);
> $newCategory = strtolower($category);
> $category = $newCategory;
> switch ($testCat){
> case 0: $sql_statement = "SELECT * from $table_name where Category =
> \"$category\";";
> $theTitle = strtoupper($category);
> break;
> case 1: $sql_statement = "SELECT * from $table_name where Vendor =
> \"$supplier\";";
> $theTitle = strtoupper($supplier);
> break;
> default: exit;
> }
> .
> .
> .
> $theScreen .= "<script language=\"javascript\">";
> //--------------------------------------------------------------------------
> --------------------------------------NewWindow function
> //--------------------------------------------------------------------------
> ------------------------------------- which process correctly when PHP is
> hot introduced
> $theScreen .= "function NewWindow(mypage){";
> $theScreen .= "var scroll = 'yes';";
> $theScreen .= "var myname = 'temp';";
> $theScreen .= "var winl = (screen.width - 875) / 2;";
> $theScreen .= "var wint = (screen.height - 650) / 2;";
> $theScreen .= "winprops =
> \"height=625,width=850,top=50,left=100,scrollbars=yes\";";
> $theScreen .= " win = window.open(mypage, myname, winprops);";
> $theScreen .= "if (parseInt(navigator.appVersion) >= 4) {
> win.window.focus(); }";
> $theScreen .= "}";
> //----------------------------------------------------------------------
> //-----------------------------------------------closeNewWindow function
> //----------------------------------------------------------------------
> $theScreen .= "function closeNewWindow(){";
> $theScreen .= " window.close();";
> $theScreen .= "}";
> .
> .
> .
> if ($outputCounter > 1){
> //--------------------------------------------
> //--------------------------- the red up arrow
> //--------------------------------------------
> $theScreen .= "<td width=110px>";
> $theScreen .= "<a href=\"#top\"><img
> src=\"d:\\html\\frogpond\\images\\arrow_red_up.jpg\" border=0>";
> $theScreen .= "&nbsp;Top</a><br>";
> //---------------------------------------------------------
> //--------------------------------------------------------------------------
> ------------------------------------------- indicate to create the
> temporderfile.html file
> //--------------------------------------------------------------------------
> ------------------------------------------- here is the problem code !!!
> //---------------------------------------------------------
> $TheParameters = "<? output_order_to_file(); ?>;
> ";  ------------------------------------------- when this is omitted, the
> pup-up window is generated
>
> //--------------------------------------------------------------------------
> ------------------------------------------- indicate to open a new window
> //--------------------------------------------------------------------------
> ------------------------------------------- which operates correctly when
> the above instruction is
> //--------------------------------------------------------------------------
> ------------------------------------------- not present
> $TheParameters .= "NewWindow(this.href); return false;";
> //--------------------------------------------------------------------------
> ------------------------------------------- the need is to write the PHP
> report to via output_order_to_file()
> //--------------------------------------------------------------------------
> ------------------------------------------- and display it in the pop-up
> window via NewWindow(this.href)
> //---------- when $TheParameters = "<? output_order_to_file(); ?>;
> NewWindow(this.href)";  ... PHP really gets a headache, which is passed on
> to me
> //--------------------------------------------------------------------------
> ----
> //--------------------------------------------------------------------------
> -------------------------------------------html file the new window will
> display
> //--------------------------------------------------------------------------
> ----
> $theScreen .= "<a href=\"temporderfile.html\" onclick=\"$TheParameters\">";
> //--------------------------------------------------------------------------
> ----------------------------------------- output the shopping cart image
> $theScreen .= "<img border=0 ";
> $theScreen .= "src=\"d:\html\frogpond\images\shopping-cart-image.gif\">";
> $theScreen .= "&nbsp;Check Cart</a><br>";
> //--------------------------------------------------------------------------
> ---------------------------------------- the red down arrow
> $theScreen .= "<a href=\"#bottom\"><img
> src=\"d:\\html\\frogpond\\images\\arrow_red_down.jpg\" border=0>";
> $theScreen .= "&nbsp;Bottom</a>";
> $theScreen .= "</td>";
> $outputCounter = 0;
> } else {
> //--------------------------------------------------------------------------
> -------------------------------------- generate a blank box as the last td
> $theScreen .= "<td>";
> $theScreen .= "&nbsp;";
> $theScreen .= "</td>";
> }
> $outputCounter++;
> $theScreen .= "</tr>";
> }
> $theScreen .= "<tr>";
> $theScreen .= "<td colspan=3 align=center>";
> if ($MYSTATUS == $TEST){
> $theScreen .= "<H2><A HREF=\"d:\\html\\frogpond\\b.html\"><BR><BR>TO
> MENU</A></H2></td>";
> } else {
> $theScreen .= "<H2><A HREF=\"b.html\"><BR><BR>TO MENU</A></H2></td>";
> }
> $theScreen .= "</tr>";
> $theScreen .= "</table>";
> $theScreen .= "</form>";
> $theScreen .= "<a name=bottom>";
> $theScreen .= "<script language=\"javascript\">";
> $theScreen .= "WriteFrogPondGourmet();";
> $theScreen .= "</script>";
> $theScreen .= "</BODY>";
> $theScreen .= "</HTML>";
> print ($theScreen);
> ?>
>
> Bob Sears
> Application Developer/Programmer
> Internet --> Mainframe, Unix/Aix, OS/JCL
> HTML, PHP, Perl, Javascript, VBScript, VB, C, COBOL, C++, Fortran, RPG and
> 21 more
> Informix, MySQL, Total
> 317-882-8056 (residence)
> 317-488-5022 (office)
> [EMAIL PROTECTED]
> Resume on-line: <http://www.on-net.net/~rsears/resumes/bob/bob.html>
> Site samples : <http://www.on-net.net/~rsears/webwyshez/webwyshez.html>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to