www.webdeveloper.com
Results 1 to 1 of 1

Thread: open and close new windows

  1. #1
    Join Date
    Aug 2004
    Posts
    1

    open and close new windows

    I have three forms: showparts.php,showupdate.php and showchange.php.

    The goal is for the user to select change in showparts, make a qty change and have that change show back in showparts.

    What is happening is when the user clicks on change a new window opens that lets the user change a qty. then submites this to showchange.php. This works fine but when the user clicks close window that window becomes showparts.php with the correct values. What I need to do is have the new window close and have the changes reflected in the origional showparts.php.
    The flo is from showparts to showupdate to showchange

    following is the code for all three pages. Any and all help would be appreciated.


    [hr]
    Selectparts.php
    <?php
    #####################
    #
    # set QuoteID cookie to be used throughout the script
    #
    ####################
    setcookie("thisQuote","$QuoteID",time()+3600);
    global $ItemID,$qty,$thisquote;

    ?>
    <?php
    include ("header.php");
    ?>
    <html>
    <head>
    <script language=javascript>
    var detailsWindow;
    function showDetails(pageURL)
    {
    detailsWindow = window.open(pageURL,"partDetails","width=400,height=400");
    detailsWindow.focus();
    return false;
    }

    var updateWindow;
    function showUpdate(pageURL)
    {
    window.close;
    updateWindow = window.open(pageURL,"partDetails","width=400,height=400");
    updateWindow.focus();


    return false;
    }
    </script>
    </head>
    <body>


    <table border=1 align=center width=75%>
    <colgroup>
    <col width=40%>
    <col width=30%>
    <col width=5%>
    <col width=0*>
    <col width=15%>
    <?php
    $grandtotal=0;
    $i=1;


    [t]$result=mysql_query("select * from itemmaster where CatagoryID='$CatagoryID'");
    echo "<tr><th colspan=6 align=left>Description</th></tr>";
    [t]while($myrow=mysql_fetch_array($result))
    [t]{
    [t]
    [t]echo "<form name=$i method=post action=showParts.php>";
    ?>
    <tr>
    <td><?php echo "$myrow[Description]";?></td>
    <td align=center><input type=button value="Show Details" onclick="return showDetails('showdetail.php?ItemID=<?php echo "$myrow[ItemID]";?>')"></td>
    <td align=center><font color=red> or </font></td>
    <input type=hidden name=flag value=A>
    <td align=center><input type=submit name=addDetails value=Add></td>
    <input type=hidden name=QuoteID value=<?php echo "$QuoteID";?>><input type=hidden name=PartNum value=<?php echo "$myrow[PartNum]";?>><input type=hidden name=ItemID value=<?php echo "$myrow[ItemID]";?>>
    <?php
    echo "<td align=center>Qty: <input type=text name=qty size=3></td> </tr>";

    echo "<input type=hidden name=CatagoryID value=$CatagoryID></form>";
    [t]$i=$i+1;
    [t]}
    echo "</table>";

    #########################
    # need to create new window
    ########################
    echo "<table align=center border=1 width=75%>";

    ###################add section#########################
    if($flag='A')
    {
    $sql="insert into quotedetail(QuoteID,ItemID,Qty)values('$QuoteID','$ItemID','$qty')";
    $result=mysql_query($sql);

    $result=mysql_query("select * from itemmaster,quotedetail where quotedetail.QuoteID='$thisQuote' and itemmaster.ItemID=quotedetail.ItemID");
    echo "<tr><th>&nbsp</th><th>Description</th><th>Part Number</th><th>Qty</th><th>Unit Price</th><th>Extended Price</th></tr>";
    [t]while($myrow=mysql_fetch_array($result))
    [t]{
    ####################
    # get extended total for each part and
    # format to currency
    ###################
    [t]$total=$myrow['Qty']*$myrow['price'];
    [t]$grandtotal=$grandtotal+$total;
    [t]$total=number_format($total,2);
    ?>
    <tr>
    <td><input type=button value="Change Qty"
    [t]onclick="return showUpdate('showupdate.php?DetailID=<?php echo "$myrow[DetailID]";?>')" target=self></td>
    <?php
    echo "<td>$myrow[Description]</td><td>$myrow[PartNum]</td><td>$myrow[Qty]</td><td>\$$myrow[price]</td><td> \$$total </td></tr>";
    [t]}
    }
    else
    {
    #########################update section#########################
    $result=mysql_query("select * from itemmaster,quotedetail where quotedetail.QuoteID='$thisQuote' and itemmaster.ItemID=quotedetail.ItemID");
    echo "<tr><th>&nbsp</th><th>Description</th><th>Part Number</th><th>Qty</th><th>Unit Price</th><th>Extended Price</th></tr>";
    [t]while($myrow=mysql_fetch_array($result))
    [t]{
    ####################
    # get extended total for each part and
    # format to currency
    ###################
    [t]$total=$myrow['Qty']*$myrow['price'];
    [t]$grandtotal=$grandtotal+$total;
    [t]$total=number_format($total,2);
    ?>
    <tr>
    <td><input type=button value="Change Qty"
    [t]onclick="return showUpdate('showupdate.php?DetailID=<?php echo "$myrow[DetailID]";?>')"></td>
    <?php
    echo "<td>$myrow[Description]</td><td>$myrow[PartNum]</td><td>$myrow[Qty]</td><td>\$$myrow[price]</td><td> \$$total </td></tr>";
    [t]}
    }
    [t]
    [t]
    $grandtotal=number_format($grandtotal,2);
    echo "<tr><td colspan=5 align=right>Grand total</td><td>\$$grandtotal";

    ?>

    </table>
    </body>
    </html>
    [hr]
    showupdate.php
    <?php
    include ("header.php");
    ?>
    <html>
    <head>
    <script language=javascript>
    function button_close()
    {
    window.close();
    }
    </script>
    </head>
    <body>
    <form name=close method=put action=showchange.php>
    <?php
    ###########################################
    # make changes section
    ##########################################

    echo "<table width=75% align=center border=1>";
    $result=mysql_query("select * from itemmaster,quotedetail where quotedetail.DetailID='$DetailID' and itemmaster.ItemID=quotedetail.ItemID");
    #$result=mysql_query("select * from quotedetail where DetailID='$DetailID'");
    while($myrow=mysql_fetch_array($result))
    {
    echo "<tr><td>Part Number</td><td>$myrow[PartNum]</td></tr>
    <tr><td>Description</td><td>$myrow[Description]</td></tr>
    <input type=hidden name=DetailID value=$myrow[DetailID]>
    <input type=hidden name=changedQty value=1>
    <tr><td>Qty.</td><td><input type=text name=Qty value=$myrow[Qty] size=3></td></tr>";
    }
    echo "<tr><td align=center><input type=submit name=change value=Update></td></tr><table>";
    ?>

    <br><BR>
    <input type=submit value="Close Window" onclick="button_close()">
    </form>
    </body>
    </html>
    [hr]
    showchange.php
    <?php
    include("header.php");
    ?>
    <html>
    <head>
    <script language=javascript>
    var detailsWindow;
    function button_close()
    {

    window.close();
    window.parent.location=showparts.php;
    return false;
    }

    </script>
    </head>
    <body>
    <form name=changeQty method=post action=showparts.php>
    <?php
    $sql="update quotedetail set Qty='$Qty' where DetailID='$DetailID'";
    $reslt=mysql_query($sql);

    echo "<table width=75% align=center border=1>";
    $result=mysql_query("select * from itemmaster,quotedetail where quotedetail.DetailID='$DetailID' and itemmaster.ItemID=quotedetail.ItemID");
    while($myrow=mysql_fetch_array($result))
    {
    echo "<tr><td>Part Number</td><td>$myrow[PartNum]</td></tr>
    <tr><td>Description</td><td>$myrow[Description]</td></tr>
    <input type=hidden name=DetailID value=$myrow[DetailID]>
    <input type=hidden name=QuoteID value=$myrow[QuoteID]>
    <input type=hidden name=CatagoryID value=$myrow[CatagoryID]>
    <input type=hidden name=flag value=U>
    <tr><td>Qty.</td><td>$myrow[Qty]</td></tr></table>";
    }

    ?>

    <br><BR>

    <input type=submit value="Close Window" onclick="window.location='showparts.php' "target="_parent">
    </form>
    </body>
    </html>
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles