Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a for do 2 actions?

Status
Not open for further replies.

echostorm

Vendor
Apr 10, 2005
28
AU
Hey all,

Is it possible to perform to actions in a form? i.e. have the form do both of these functions?

Code:
<form action="#" onsubmit="handleCartItem(this);return false;">
and
Code:
<form name="order" method="post" action="stockorder.php">
 
no. what you need to do is have two forms - but only one with a submit button. when you hit that button, it sets of the javascript, and then you have at the end of that script a form2.submit() call which will promptly set off the one which had an 'action' tag.
 

gormster,

Your solution may not always work... If form1 gets submitted before the Javascript has had a chance to submit form2, form2 will never be submitted.

echostorm,

Why do you need to perform two form actions at the same time? Maybe there is a way around this?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
As long as you want handleCartItem to be called before the form is posted to stockorder.php, just combine the two line this:
Code:
<form name="order" method="post" action="stockorder.php" onsubmit="return handleCartItem(this);">
And make sure that handleCartItem returns true if you want the form to submit.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top