Page 1 of 1

JavaScript Error Box Problem

Posted: Wed May 04, 2005 3:32 pm
by mmc01ms
Im trying to get a javascript box which asks if you are sure you wish to delete an item from your order etc. The Javascript box appears however when yes is selected it wont do anything and it wont go to the deleteorder.php page. The error i get in the browser window is
object doesn't support this property or method
the code is:

Code: Select all

<?php function display_outstanding_orders($order_array)
	{// used to display the outstanding orders
		if(!is_array($order_array))
		{
			echo 'No outstanding orders<br />';
			return;
		}
		
		{
?>

<script> 
	function checkIt(){ 
		if(confirm("Cancel Order?")){ 
			document.MyForm.submit();
			//return true; 
		} 
	} 
</script> 
<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>';
		}
			
			
			function delete_order($order_id, $cat_no)
				// deletes vinyl identfied by it's cat_no from the database
			{
				$link_id = db_connect();
				
				$query = "delete from ordered_items where order_id = '$order_id' and cat_no = '$cat_no'";
				$result = @mysql_query($query, $link_id) or die(mysql_error());;
				//var_export($query);
				if (!$result)
					return false;
				else
					return true;
			}

Any guidenece would be appricated.

Posted: Thu May 05, 2005 11:44 am
by anjanesh

Code: Select all

&lt;script type=&quote;text/javascript&quote;&gt;
    function checkIt(){
        if(confirm(&quote;Cancel Order?&quote;)){
            document.getElementById(&quote;MyForm&quote;).submit();
            //return true; 
        } 
    } 
&lt;/script&gt;

Code: Select all

echo '&lt;form id=&quote;MyForm&quote; action=&quote;cancelorder.php&quote; method=&quote;post&quote;&gt; ';