473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

php and Javascript

Ken
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
correctly.

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.

Thanks.

(Javascript)
function send() {
invoice.submit();
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.

(Javascript)
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="http://www.domainname.com/php/emailc.php" method="post">
<table>
<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>
</table>
</form>
I cannot use type=submit in invoice.submit().

emailc.php
<?php
error_reporting(E_ALL);
//error_reporting(0);
$date = date('F j, Y');
$fname = $_POST['f_name'];
$message = "$date \n\n $fname";
$to = em*******@domainname.com;
$subject = "$fname , $date";
mail($to, $subject, $message);
?>

<form name="transfer" action="http://www.different domain name1.com"
method="post">
<input type="hidden" name="first_name">
</form>
<br><br>
<input type="image" src="http://www.different domain name1/image.gif"
value="Try this" onclick="send()">
Jan 6 '08 #1
3 1979
Ken wrote:
>I am trying to run two form.submit() in sequence when clicking on
<input image... ..."try this"
I suspect you would be better asking this in comp.lang.javascript
Jan 6 '08 #2
Ken wrote:
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
correctly.

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.
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.
bill
Jan 6 '08 #3
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.
Jan 6 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.