Javascript/PHP probelm
Posted: Wed Mar 02, 2005 5:29 pm
I've created a script which displays a list of orders. If a customer wishes to cancel an order some javascript asks if they are sure selecting yes will execute to the cancelorder script. The problem is once yes is selected nothing happens and an error box appears in the bottom of the browser saying:
object doesn't support this method?
object doesn't support this method?
Code: Select all
<?php
//myaccount_functions.php written by Manpreet Sandhu 13/02/2005
require_once('shopping_basket_fns.php');
?>
<script>
function checkIt(){
if(confirm("Cancel Order?")){
document.MyForm.submit();
//return true;
}
}
</script>
<?php
function get_outstanding_order_details($customer_id){
//connects to the database and creates an array with the outstanding orders
$link_id = db_connect();
$query = "select orders.delivery_charge, orders.order_id, orders.customer_id, orders.total, ordered_items.cat_no, vinyls.title, vinyls.price, ordered_items.order_item_status, orders.date_order_placed
from orders , ordered_items , vinyls
where orders.order_id = ordered_items.order_id
and ordered_items.cat_no = vinyls.cat_no
and ordered_items.order_item_status = 'On Order'
or ordered_items.order_item_status = 'Awaiting Stock'
order by date_order_placed desc";
$result = @mysql_query($query, $link_id) or die ("There was a problem with this query.");
if (!$result)
return false;
$num_orders = @mysql_num_rows($result);
if($num_orders == 0)
return false;
$result = db_result_to_array($result);
return $result;
}
function display_outstanding_orders($order_array)
{// used to display the outstanding orders
if(!is_array($order_array))
{
echo 'No outstanding orders<br />';
return;
}
{
?>
<table bgcolor="#7b9815" border="0" bordercolor="FFFFFF" cellpadding="0" cellspacing="0">
<th width="425">Outstanding Orders</th>
</table>
<br>
<table bgcolor="#7b9815" border="1" bordercolor="FFFFFF" cellpadding="0" cellspacing="0">
<font color="#000000" size="1" face="Arial, Helvetica, sans-serif"><th>Order Date</th><th>Item</th><th>Price</th><th>Status</th></font>
<?
}
foreach ($order_array as $row)
{//while an order still exists in the array loop round and display again.
$url = 'show_vinyls.php?cat_no='.($rowї'cat_no']);
$title = $rowї'title'];
$price = $rowї'price'];
$order_date = $rowї'date_order_placed'];
$status = $rowї'order_item_status'];
$cat_no = $rowї'cat_no'];
$order_id = $rowї'order_id'];
{
?> <tr>
<?
}
print '<tr>';
print '<td>';
echo $rowї'date_order_placed'];
echo '</td>';
//echo '<td>';
print do_html_url($url,$title);
echo '</td>';
echo '<td>';
echo $rowї'price'];
echo '</td>';
echo '<td>';
echo $rowї'order_item_status'];
echo '</td>';
echo '<td>';
echo '<form name="MyForm" action="cancelorder.php"> ';
echo '<input type="button" value="Cancel Order" onClick="checkIt();"> ';
echo '<input type="hidden" name="cat_no" value="'.$rowї'cat_no'].'">';
echo '</form>';
echo '</td>';
echo '</tr>';
}
echo '</table>';
}