php and Javascript

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am trying to run two form.submit() in sequence when clicking on <input  
image...  ..."try this"

When calling send() with only invoice.submit active, the form invoice works  

When calling send() with only setTimeout("transfer.submit()", 10000), the  
form transfer works correctly.

When both are active, the php script runs and sends an email but the  
transfer.submit does not work.

Data is entered in invoice and forwarded in transfer.
I left out some script to simplify the posting.

Suggestions would be appreciated.  I have spent the entire day trying  
different things with no success.


function send() {
  setTimeout("transfer.submit()", 10000);

I thought it was a timing problem so I added a time delay which did not  
solve the problem.  Without the delay, the script has the same problem.

function calculateinvoice() {
transfer.first_name.value = invoice.f_name.value;

invoice.submit calls a php script which emails the data.
<form name="invoice" enctype="multipart/form-data"  
action=" " method="post">
<tr><td align="left"> &nbsp;First Name:</td><td colspan="5"  
align="left"><input type="text" name="f_name" size="25"></td></tr>
<input name="button1a" type="button" class="arial-10"  
onClick="calculateinvoice()" value="Calculate"></td></tr>
I cannot use type=submit in invoice.submit().

$date = date('F j, Y');
$fname = $_POST['f_name'];
$message = "$date \n\n $fname";
$to =;
$subject = "$fname , $date";
mail($to, $subject, $message);

<form name="transfer" action="http://www.different domain"  
<input type="hidden" name="first_name">
<input type="image" src="http://www.different domain name1/image.gif"  
value="Try this" onclick="send()">

Re: php and Javascript

Ken wrote:
Quoted text here. Click to load it
I suspect you would be better asking this in comp.lang.javascript  

Re: php and Javascript

Ken wrote:
Quoted text here. Click to load it

You can not reliably submit a form twice or two forms from one  
client.  It depends on how fast the client is and how fast the  
net is.  Once you submit the first form, you may or may not still  
have a client present when the second form is to be sent.

This is something best handled on the server side.

Re: php and Javascript

Heya, Ken.

Submitting a form sends a new HTTP request, so you'll need to either
combine the two forms into one (give each submit button a name so that
you can keep track of which button the User clicked), or you can use
AJAX to send the first form's results.

Site Timeline