faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 4 people (100%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

I need to have my on submit statement refer to multiple functions, how can I do that?

Apr 7th, 2008 23:28
ha mo, Colin Fraser, james stone,


There are a couple of ways of doing this firstly, try:
<form onSubmit="doTheseThings()" name="myForm">
   <! form inputs etc.... ---->
   <br>
   <input type="submit" value="Send data"> 
   <input type="reset" value="Clear form">
</form> 
and the function :
<script language="JavaScript"><!--
function doTheseThings() {
    doThisFirst()
    doThisNext()
    doThisLast()
}
//--></script>
the last function here can be : 
<script language="JavaScript"><!--
function doThisLast() {
   document.myForm.submit();
}
//--></script>
I have used this before and it works, as long as all your functions do
what they should do and not mess anything up.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com