View Full Version : Div not working in PHP
Jim Weinberg
07-30-2012, 04:28 PM
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.
jscheuer1
07-30-2012, 04:51 PM
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.
Jim Weinberg
07-30-2012, 05:23 PM
Okay, here goes:
HTML 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&cPath=0&products_id=2&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> <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:
<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&cPath=0&products_id=".$id."&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> <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.
Jim Weinberg
07-30-2012, 08:49 PM
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. :eek:
Jim Weinberg
07-30-2012, 09:18 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.