SOLVED - confirm() with textarea submission

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

SOLVED - confirm() with textarea submission

Post by johnperkins21 »

I'm trying to use a confirm() with a textarea box, where the the value of the text gets added to the db. My problem is that I type text into the text box, but it never seems to get submitted. I am completely lost, if anyone has any suggestions, I am open to any help you can offer.

Here is the entire code for the page:

Code: Select all

<?php
<?
include "../db_connect.php3";
?>
<html>
<head>

<SCRIPT LANGUAGE="Javascript">
<!---
function decision(oid,cust) {
	ok = "/control/cancel_order.php3?a=cancel&OrderNumber=" + oid;
	cancel = "/control/view_order.php?oid=" + oid + "&CustNum=" + cust;
	answer = confirm("Do you really want to cancel this order?");
	if (answer) {
		location = ok;
	} else {
		location = cancel;
	}
	
}
// --->
</SCRIPT>
<title>Discount Dance Supply Order Cancellation</title></head>
<body bgcolor=#ffffff>
<center>
<br>
<table border=1 cellpadding=0 cellspacing=0>
<tr>
<td colspan=7 bgcolor=#6666cc align=center>
<font face=verdana,arial,helvetica size=-1 color=#ffffff><b>&nbsp;Discount Dance Supply Order Cancellation&nbsp;</b></font>
</td>
</tr>
<tr>
<td valign=top align=center>
<?

	if($OrderNumber && $a=="cancel")  {
		$Notes = $_POST[Notes];
		$cancel_handle=mysql_db_query($db,"INSERT into Order_Status_Header values (0,$OrderNumber,$OrderNumber,0,now(),'','','','$Notes')");
		#$cancel_handle2 = mysql_db_query($db, "UPDATE Order_Header SET DownloadBatch=1 WHERE OrderNumber=$OrderNumber");

	}
?>
<form method=POST name=addressForm>
<table border=0 cellpadding=2 cellspacing=0>
<tr>
<td valign=top><font face=arial,helvetica style="font-size: 9pt;">
<?
if($OrderNumber) {
	$status_handle=mysql_db_query($db,"SELECT StatusNumber from Order_Status_Header where OrderNumber=$OrderNumber and AdvantageFlag=11");
	$download_batch = mysql_db_query($db, "SELECT DownloadBatch FROM Order_Header where OrderNumber=$OrderNumber and DownloadBatch=1");
	if ((mysql_num_rows($status_handle) >0) || (mysql_num_rows($download_batch)) > 0 ) {
		echo "<b>Order has been cancelled</b>\n";
	}
	else {
		echo "Notes for customer display <br><textarea cols=30 rows=4 name=Notes></textarea>\n";
	}
}
?>
</td>
</tr>
<tr><td align=center colspan=2><input type=submit name="SaveChanges" value="Cancel Order" style="font-size:8pt;" ONCLICK=" decision('<? echo $OrderNumber; ?>','<? echo $CustNum; ?>'); return false;"></td></tr>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
?>
I know my documentation sux, but it should be pretty easy to figure out what's going on. The problem is with submitting the text in the textarea. I am unable to pass that on for some reason. Thanks for the help.
Last edited by johnperkins21 on Wed Feb 18, 2004 2:25 pm, edited 1 time in total.
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Solved

Post by johnperkins21 »

Okay, I got it working.

The problem was that I never really posted the form, only reloaded the page basically. So I changed my javascript function from:

Code: Select all

function decision(oid,cust) &#123; 
   ok = "/control/cancel_order.php3?a=cancel&OrderNumber=" + oid; 
   cancel = "/control/view_order.php?oid=" + oid + "&CustNum=" + cust; 
   answer = confirm("Do you really want to cancel this order?"); 
   if (answer) &#123; 
      location = ok; 
   &#125; else &#123; 
      location = cancel; 
   &#125; 
    
&#125;

to:

Code: Select all

function decision() &#123;
	answer = confirm("Do you really want to cancel this order?");
	if (answer) &#123;
		document.addressForm.submit();
	&#125; else &#123;
		location = '/control/view_order.php?oid=<? echo $OrderNumber; ?>&CustNum=<? echo $CustNum; ?>';  
	&#125;
	
&#125;
and changed my form to:

Code: Select all

<form method=POST name=addressForm action="/control/cancel_order.php3">
<input type=hidden name=a value=cancel>
<input type=hidden name=OrderNumber value=<? echo $OrderNumber; ?>>
<input type=hidden name=CustNum value=<? echo $CustNum; ?>>
One of my problems with doing this initially was that I wasn't sure if I could pass my php variables into my javascript function. Apparently it is possible.

I hope my struggle helps some other poor soul.
Post Reply