JavaScript Error Box Problem

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
mmc01ms
Forum Commoner
Posts: 97
Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK

JavaScript Error Box Problem

Post 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.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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; ';
Post Reply