Re: Multiple Submit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dan Shirah wrote:
Hello all,

I have a page that has multiple submits on it.  One submit is within my
javascriptfor form checking, the other submit is a button used to populate
all customer information if an order ID is entered.

Problem:  I cannot get the two to coincide at the same time.  They both use
the submit function to send the data to the same page instead of their
unique individual pages.

Code:  Below are the code snipets.


<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!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";>
<HEAD>
<script language="JavaScript">
<!--

function closeThis() {
if (window.confirm("Are you sure you want to cancel the payment request?"))

 this.window.close();
}

*function checkForm() {*

// ** START **
 if (inputForm.cc_phone_number.value == "") {
   alert( "Please enter a phone number." );
   inputForm.cc_phone_number.focus();
   return;
 }

  if (inputForm.receipt.value == "") {
   alert( "Please select whether or not a receipt was requested." );
   inputForm.phone_number.focus();
   return;
 }

 if (inputForm.cc_first_name.value == "") {
   alert( "Please enter a first name." );
   inputForm.cc_first_name.focus();
   return;
 }

 if (inputForm.cc_last_name.value == "") {
   alert( "Please enter a last name." );
   inputForm.cc_last_name.focus();
   return;
 }

 if (!(document.inputForm.cc_comments.value =="")) {
 if (document.inputForm.cc_comments.value.length > 250)
 {
   alert("The Comments must be less than 250 characters.\nIt is currently "
+ document.inputForm.window_name.value.length + " characters.");
  document.inputForm.window_name.focus();
  return;
 }
}
* document.inputForm.submit();*
}

//-->
</script>
<LINK rel="stylesheet" type="text/css" href="../../CSS/background.css">
</head>
<body>
*<form name="inputForm" action="save.php" method="post"
enctype="multipart/form-data">*
<table align="center" border="0" cellpadding="0" cellspacing="0"
width="680">
<tr>
   <td height="13" align="center" class="tblhead"><strong>Credit Card
Information</strong></td>
</tr>

*// LOTS OF FORM DATA REMOVED FOR EMAIL LENGTH*

<table align="center" border="0" cellpadding="0" cellspacing="0"
width="680">
<tr>
*This is the other submit that I need to go a page other than the one
specified in the <form>*
*<td width="62"><a href="DeferredPayment3.php"><input type="submit"
name="retrieve" value="Retrieve"></a></td>*
     <td width="8"></td>
</tr>
</table>
<br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0"
width="680">
<tr>
*Call to the javascript checkForm function*
*<td width="64" align="left"><a href="javascript:checkForm()"
title="Save">Save</a></td>
* <td width="616" align="left"><a href="javascript:closeThis()"
title="Close">Close</a></td>
</tr>
</table>
</form>
</body>
</html>

I see a few things now that are wrong with this. I thought they were comments but now that you have explained that it was a nested for, it make a little more sense. You cannot nest forms.

if you want to have the for submitted to a different location, then you have to use one form, with function that modify the action value and change it to the correct url and then submit the form.

Try this:

<form action="original.php" method="get" onsubmit="return false;" >
<input type="submit"
	onclick="	alert("Original:"+this.form.action);
			this.form.action = 'new.php';
			alert("New:"+this.form.action); " />
</form>



--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree.

- Rush

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux