PDA

View Full Version : HTML form problem



votter
Feb 11th, 2010, 02:47 AM
I've looked around and have seen similar posts, but didn't see one to answer this how I need it.

I have a form surrounding a table, and then a form inside of a pair of td tags.

The table shows correctly in firefox, chrome, but in IE the form causes the table to break into like a new row after the form is ended.

If you need that part of the code, I can post it. Just didn't know if anybody else had these problems.

fball
Feb 11th, 2010, 06:51 AM
Can you post the code and version of IE that you are using?

VIPStephan
Feb 11th, 2010, 12:03 PM
I have a form surrounding a table, and then a form inside of a pair of td tags.

The table shows correctly in firefox, chrome, but in IE the form causes the table to break into like a new row after the form is ended.


First error: you are probably using tables for layout. Donít do that, use semantic HTML (http://en.wikipedia.org/wiki/Semantic_HTML).

Second error: it sounds like you have some nesting errors (i. e. incorrectly closed elements). But without seeing any code nobody will be able to tell you for sure.

votter
Feb 11th, 2010, 03:02 PM
Not sure if I should move this to php forums, but if I should, I will do so.

And I couldn't paste this in any code tags cause it was not displaying some things.

<?php

require_once('db.inc.php');
if($_SESSION['cart']) {


$i = 1;
echo '<br />';
echo '<br />';
echo '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" style="margin:0px;" method="post">';
echo '<table class="iteminfo" align="center"><th>Quantity</th><th>Product(s)</th><th>Unit Price</th><th>Total Price</th>';
foreach($_SESSION['cart'] as $product_id => $quantity) {

$getiteminfo = mysql_query(sprintf("SELECT ItemName, ItemPrice FROM `***` WHERE `ItemId` = %d;", $product_id))or die (mysql_error());
if (mysql_num_rows($getiteminfo) > 0) {
list($Name, $ItemPrice) = mysql_fetch_row($getiteminfo);


$color1='#bebeb1';
$color2='#eaeada';

$bgcolor=($bgcolor==$color1)?$color2:$color1;


$line_cost = 0.00;
$line_cost = $ItemPrice * $quantity;
$total = $total + $line_cost;


echo '<tr bgcolor="'.$bgcolor.'"><td style="height:75px;><form style="margin:0px;" action="" method="post"><input type="text" class="quantity" name="amount" size="3" value="'.$quantity.'" /><br /><input type="button" onClick="updateItem(\''.$product_id.'\',amount.value, \''.$Name.'\')" class="update" value="Update!" /><br /><input type="button" onClick="removeItem(\''.$product_id.'\', \''.$Name.'\')" class="update" value="Remove!" /></form></td>';
echo '<td style="width:300px;text-align:left;"><img src="http://www.vorogh.com/Images/Nauren.jpg" alt="'.$Name.'" class="view" align="top" />'.$Name.'</td><td align="center">$'.$ItemPrice.'</td>';

echo '<td align="center">$'.number_format($line_cost, 2).'</td></tr>';
echo '<input type="hidden" name="quantity_'.$i.'" value="'.$quantity.'" /><input type="hidden" name="amount_'.$i.'" value="'.number_format($ItemPrice, 2).'" /><input type="hidden" name="item_name_'.$i.'" value="'.$Name.'" />';

$i++;
}

}

echo '<tr><td colspan="3" align="right">Total Price:</td><td>$'.number_format($total, 2).'</td></tr>';
echo '<tr><td colspan="4" style="text-align:right;"><input type="hidden" name="business" value="" /><input type="hidden" name="cmd" value="_cart" /><input type="hidden" name="upload" value="1"><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" /></td></tr>';
echo '</table>';
echo '</form>';
} else {
echo 'You have no Items in your cart';
}
?>

The file validates as passed for this file too.

Thanks again for all the help. I'll be back after school. xD.

Version 8 IE.

VIPStephan
Feb 11th, 2010, 06:36 PM
Actually the output HTML would help much more since we wouln’t have to imagine how the PHP would compose the page. Just view the source code in the browser, copy and paste it here. And for code there is the ‘#’ button (the one without the ‘i’ next to it) in the editor window.

votter
Feb 11th, 2010, 10:28 PM
hey, it shows now. xD. Thanks. :). I tried using
tags the first time, but maybe I just didn't see it or something.

[CODE]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Shopping-Cart</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<script language="javascript" type="text/javascript" src="/folder/prototype.js"></script>
<script language="javascript" type="text/javascript" src="/folder/functions.php"></script>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="banner">
<p id="cart" style="margin:0px;"><a href="viewcart.php">View Cart</a>(1)</p>

</div>
<div class="menubar">
<ul>
<li><a href="#">Home</a>|</li>
<li><a href="#">About</a>|</li>
<li><a href="#">First Visit</a>|</li>
<li><a href="supplements.php">Supplements</a>|</li>
<li><a href="#">Find Us </a>|</li>

<li><a href="#">Contact Us</a></li>
</ul>
</div>
<div id="popUp">
<p id="title"></p>
<p id="message"></p>
<p id="close"><a href="#" onclick="$('popUp').style.display='none';return false;">Close</a></p>
</div>
<div id="content" class="content">
<br /><br /><form action="https://www.sandbox.paypal.com/cgi-bin/webscr" style="margin:0px;" method="post"><table class="iteminfo" align="center"><th>Quantity</th><th>Product(s)</th><th>Unit Price</th><th>Total Price</th><tr bgcolor="#bebeb1"><td style="height:75px;><form style="margin:0px;" action="" method="post"><input type="text" class="quantity" name="amount" size="3" value="2" /><br /><input type="button" onClick="updateItem('3',amount.value, 'A-F Betafood&reg;')" class="update" value="Update!" /><br /><input type="button" onClick="removeItem('3', 'A-F Betafood&reg;')" class="update" value="Remove!" /></form></td><td style="width:300px;text-align:left;"><img src="http://www.***.com/Images/Nauren.jpg" alt="A-F Betafood&reg;" class="view" align="top" />A-F Betafood&reg;</td><td align="center">$129.99</td><td align="center">$259.98</td></tr><input type="hidden" name="quantity_1" value="2" /><input type="hidden" name="amount_1" value="129.99" /><input type="hidden" name="item_name_1" value="A-F Betafood&reg;" /><tr><td colspan="3" align="right">Total Price:</td><td>$259.98</td></tr><tr><td colspan="4" style="text-align:right;"><input type="hidden" name="business" value="" /><input type="hidden" name="cmd" value="_cart" /><input type="hidden" name="upload" value="1"><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" /></td></tr></table></form></div>

<div class="footer">
&copy; 2010
<br />
text
</div>
</div>
</body>
</html>

VIPStephan
Feb 11th, 2010, 10:54 PM
I should have said that right away (and I even saw something in the PHP you posted) but before you ask us for help please send your code through the validator (http://validator.w3.org/) and fix the errors. You can’t expect perfect results and cross-browser compatibility from erroneous code.

Come back if the problem still persists after fixing the errors. :)

votter
Feb 12th, 2010, 12:05 AM
Here's the new code output:




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Shopping-Cart</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<script language="javascript" type="text/javascript" src="/folder/prototype.js"></script>
<script language="javascript" type="text/javascript" src="/folder/functions.php"></script>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="banner">
<p id="cart" style="margin:0px;"><a href="viewcart.php">View Cart</a>(1)</p>

</div>
<div class="menubar">
<ul>
<li><a href="#">Home</a>|</li>
<li><a href="#">About Dr. Alter</a>|</li>
<li><a href="#">First Visit</a>|</li>
<li><a href="supplements.php">Supplements</a>|</li>
<li><a href="#">Find Us </a>|</li>

<li><a href="#">Contact Us</a></li>
</ul>
</div>
<div id="popUp">
<p id="title"></p>
<p id="message"></p>
<p id="close"><a href="#" onclick="$('popUp').style.display='none';return false;">Close</a></p>
</div>
<div id="content" class="content">
<br /><br /><form action="https://www.sandbox.paypal.com/cgi-bin/webscr" style="margin:0px;" method="post"><table class="iteminfo" align="center"><tr><th>Quantity</th><th>Product(s)</th><th>Unit Price</th><th>Total Price</th></tr><tr bgcolor="#bebeb1"><td style="height:75px;"><form style="margin:0px;" action="" method="post"><input type="text" class="quantity" name="amount" size="3" value="2" /><br /><input type="button" onclick="updateItem('3',amount.value, 'A-F Betafood&reg;')" class="update" value="Update!" /><br /><input type="button" onclick="removeItem('3', 'A-F Betafood&reg;')" class="update" value="Remove!" /></form></td><td style="width:300px;text-align:left;"><img src="http://www.vorogh.com/Images/Nauren.jpg" alt="A-F Betafood&reg;" class="view" align="top" />A-F Betafood&reg;</td><td align="center">$129.99</td><td align="center">$259.98<input type="hidden" name="quantity_1" value="2" /><input type="hidden" name="amount_1" value="129.99" /><input type="hidden" name="item_name_1" value="A-F Betafood&reg;" /></td></tr><tr><td colspan="3" align="right">Total Price:</td><td>$259.98</td></tr><tr><td colspan="4" style="text-align:right;"><input type="hidden" name="business" value="" /><input type="hidden" name="cmd" value="_cart" /><input type="hidden" name="upload" value="1" /><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" /></td></tr></table></form></div>

<div class="footer">
&copy; 2010
<br />
text
</div>
</div>
</body>
</html>


It still outputs the same in IE8.

Validated it inside out i think, just get this warning in the direct input one:

Info Using Direct Input mode: UTF-8 character encoding assumed

votter
Feb 12th, 2010, 11:15 PM
And the form action for the paypal button doesn't work either in IE, so I assume I have to re-arrange the code so that it all works out together. If there are any suggestions, would be glad to hear.

Thanks again for all the help. :)



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Shopping-Cart</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<script language="javascript" type="text/javascript" src="/folder/prototype.js"></script>
<script language="javascript" type="text/javascript" src="/folder/functions.php"></script>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="banner">
<p id="cart" style="margin:0px;"><a href="viewcart.php">View Cart</a>(<?php echo $count; ?>)</p>
</div>
<div class="menubar">
<ul>
<li><a href="#">Home</a>|</li>
<li><a href="#">About Dr. Alter</a>|</li>
<li><a href="#">First Visit</a>|</li>
<li><a href="supplements.php">Supplements</a>|</li>
<li><a href="#">Find Us </a>|</li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
<div id="popUp">
<p id="title"></p>
<p id="message"></p>
<p id="close"><a href="#" onclick="$('popUp').style.display='none';return false;">Close</a></p>
</div>
<div id="content" class="content">
<?php

require_once('db.inc.php');
if($_SESSION['cart']) {


$i = 1;
echo '<br />';
echo '<br />';

echo '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
echo '<table class="iteminfo" align="center"><tr><th>Quantity</th><th>Product(s)</th><th>Unit Price</th><th>Total Price</th></tr>';

foreach($_SESSION['cart'] as $product_id => $quantity) {
$getiteminfo = mysql_query(sprintf("SELECT ItemName, ItemPrice FROM `Vitamins` WHERE `ItemId` = %d;", $product_id))or die (mysql_error());
if (mysql_num_rows($getiteminfo) > 0) {
list($Name, $ItemPrice) = mysql_fetch_row($getiteminfo);


$color1='#bebeb1';
$color2='#eaeada';

$bgcolor=($bgcolor==$color1)?$color2:$color1;


$line_cost = 0.00;
$line_cost = $ItemPrice * $quantity;
$total = $total + $line_cost;


echo '<tr bgcolor="'.$bgcolor.'"><td style="height:75px;"><input type="text" class="quantity" name="amount" size="3" value="'.$quantity.'" /><br /><input type="button" onclick="updateItem(\''.$product_id.'\',amount.value, \''.$Name.'\')" class="update" value="Update!" /><br /><input type="button" onclick="removeItem(\''.$product_id.'\', \''.$Name.'\')" class="update" value="Remove!" /></td>';
echo '<td style="width:300px;text-align:left;"><img src="http://www.vorogh.com/Images/image.jpg" alt="'.$Name.'" class="view" align="top" />'.$Name.'</td><td align="center">$'.$ItemPrice.'</td>';

echo '<td align="center">$'.number_format($line_cost, 2).'<input type="hidden" name="quantity_'.$i.'" value="'.$quantity.'" /><input type="hidden" name="amount_'.$i.'" value="'.number_format($ItemPrice, 2).'" /><input type="hidden" name="item_name_'.$i.'" value="'.$Name.'" /></td></tr>';


$i++;
}

}

echo '<tr><td colspan="3" align="right">Total Price:</td><td>$'.number_format($total, 2).'</td></tr>';
echo '<tr><td colspan="4" style="text-align:right;"><input type="hidden" name="business" value="" /><input type="hidden" name="cmd" value="_cart" /><input type="hidden" name="upload" value="1" /><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" onclick="submit();" /></td></tr>';
echo '</table>';
echo '</form>';
} else {
echo 'You have no Items in your cart';
}
?>
</div>
<div class="footer">
&copy; 2010 Alter Chiropractic
<br />
text
</div>
</div>
</body>
</html>