Results 1 to 5 of 5

Thread: Div not working in PHP

  1. #1
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Div not working in PHP

    I don't know if this is a PHP problem or an HTML problem.

    I have an HTML page that I just converted to PHP. In the original page I had a fade-in/fade-out pop-up box that vwphillips was kind enough to send me. The pop-up box is defined in a DIV and controlled by a javascript routine. It's supposed to show when a form is submitted.

    It works fine in the HTML page, but in the PHP page, the pop-up box displays when the page is loaded.

    Any ideas?

    btw, I made sure the DIV was defined AFTER the closing PHP marker.
    Last edited by Jim Weinberg; 07-30-2012 at 04:33 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If the form submits to the same page and its method is or was GET and the way the javascript determines whether or not the form has been submitted is by looking to see if there is a query string (in javascript called location.search, but can be detected other ways) in the URL, and if the PHP page has one by default, that could be it.

    A lot of ifs.

    To actually determine the cause for sure, I'd have to see both pages - the one where it works as desired, and the one where it does not.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Okay, here goes:

    HTML Code:
    Code:
    <head>
    </style>
    <style type="text/css">
    #message {
      position:absolute;z-Index:101;left:-3000px;top:-3000px;width:430px;
    }
    </style>
    </head>
    
    <body>
    :
    : misc. code
    :
    <table width="90%" border="5" bordercolorlight="#D0C9B7" bordercolordark=#4E4B3D cellpadding="10" cellspacing="5" bgcolor="#CDC5B0">
    <tr>
    <td colspan=6 align="right"><a href="http://alongcrazyalley.com/store/index.php?main_page=shopping_cart">View Cart</a></td>
    </tr><tr>
    
    <?php include("table_build.php"); ?>
    
    </table>
    <form name="cart_quantity" action="http://alongcrazyalley.com/store/index.php?main_page=product_info&amp;cPath=0&amp;products_id=2&amp;action=add_product" method="post" enctype="multipart/form-data"  onsubmit="return Message(this,'message',1000,2000)">
    <input type="hidden" name="cart_quantity" value="1" /><input type="hidden" name="products_id" value="2" /><input type="image" src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " />
    </form>
     <div id="message" >
     <table border=2 width=450px bgcolor="#C0C0C0"><tr><td>
      <center><p>Your button has been added to the shopping cart.<p>&nbsp;<br>Please click on "View Cart" to review your purchases and checkout.
      </td></tr></table>
     </div>
    <script src="SCMessage.js"></script>
    <p><img src="Graphics/h1.gif" height=20 width="100%">
    <p>
    <a href="mailto:m.j.weinberg@earthlink.net?subject=Wild Wednesday Order">Email me your order</a>
    </body>

    PHP Code:
    Code:
    <head>
    </style>
    <style type="text/css">
    #message {
      position:absolute;z-Index:101;left:-3000px;top:-3000px;width:430px;
    }
    </style>
    </head>
    
    <body>
    :
    : misc. html code
    :
    <table width="90%" border="5" bordercolorlight="#D0C9B7" bordercolordark=#4E4B3D cellpadding="10" cellspacing="5" bgcolor="#CDC5B0">
    <tr>
    <td colspan=6 align="right"><a href="http://alongcrazyalley.com/store/index.php?main_page=shopping_cart">View Cart</a></td>
    </tr><tr>
    <!-- Buttons should be scanned at 300 x 300 pixels-->
    
    <?php
    // Fill table
    $result = mysql_query("SELECT * FROM zen_products_description");
     $result1 = mysql_query("SELECT * FROM zen_products");
    if($result) {
     $count = 1;
     while($row = mysql_fetch_array($result))  {
      $row1 = mysql_fetch_array($result1);
      $id = $row["products_id"];
      $name = $row["products_name"];
      $description = $row["products_description"];
      $price = $row1["products_price"];
      $image = "../store/images/".$row1["products_image"];
      $quantity = $row1["products_quantity"];
      if ($quantity == 0) {
        $price = "<i><b><font color='Red'>Sold</font></b></i>";
      }
      $popup = ' onclick = "return Message(this,'."'message'".',1000,2000)"';
      
      $part1 .= "<td align='center'><a href='".$image."' class='MagicThumb'><img width=125 src=".$image."></a>";
      $part2 .= "<td align='center' bgcolor='#Ded9ce'><form name='cart_quantity' action='http://alongcrazyalley.com/store/index.php?main_page=product_info&amp;cPath=0&amp;products_id=".$id."&amp;action=add_product' method='post' enctype='multipart/form-data' target='zenframe'".$popup.">";
      $part2 .= "<br><font size=-1 face='Verdana'>".$name."<br>".$description."<br>".$price;
      if ($quantity != 0) {
        $part2 .= "<br><input type='hidden' name='cart_quantity' value='1' /><input type='hidden' name='products_id' value='".$id."' /><input class='hoverable add_to_cart_button' title='Add to Cart' alt='Add to Cart' type='submit' value='Buy Now' /></form>";
      }
      $part1 .= "</td>";
      $part2 .= "</td>";
      $count = $count + 1;
      if ($count > 4) {
        print ($part1);
        print("</tr><tr>");
        print ($part2);
        print("</tr><tr>");
        $count=1;
        $part1='';
        $part2='';
      }
     }
    }
    ?>
    </tr>
    </table>
    </form>
    
    <div id="message" >
     <table border=2 width=450px bgcolor="#C0C0C0"><tr><td>
      <center><p>Your button has been added to the shopping cart.<p>&nbsp;<br>Please click on "View Cart" to review your purchases and checkout.
      </td></tr></table>
     </div>
     <script src="SCMessage.js"></script>
    
    <iframe id="cart_frame" src="../store/index.php?main_page=shopping_cart" name="zenframe" width="0" height="0" style="visibility:hidden"></iframe>
    <p>
    <p><img src="Graphics/h1.gif" height=20 width="100%">
    <p>
    <center><font face="Verdana" color="black" size=3><i><b>Contact us at</i> <a href="mailto:crazy@alongcrazyalley.com?subject=ACAWW-">crazy@alongcrazyalley.com</a></b>
    In the HTML version, the PHP file simply fills the rows of the table. In the PHP version, everything is built dynamically.

    Hope this helps.
    Last edited by Jim Weinberg; 07-30-2012 at 08:49 PM.

  4. #4
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Thought I'd better add a note. I've been playing around with the code and now the DIV no longer displays when the page loads.

    The bad news is that the pop-up doesn't work at all now. I've edited the code in my earlier post to reflect the current coding.

  5. #5
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Final note: I worked some more with the code and now it works, sort of. I works the first time, but then it stops working. The original code I was sent had a null ("#") value for the Action attribute of the form. My form doesn't.

    I think the problem is with the script, so I'm going to close out this thread and reopen the one that started this all.

    Thanks to jscheuer1 for his help.

Bookmarks

Posting Permissions

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