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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Function Calls

Status
Not open for further replies.

RussellDonders

Programmer
Jun 10, 2001
27
0
0
GB
Hi,

I have a function on load page that I want to use to call several other functions to set up my page.

The problem I have is that it only executes the first function I put in the list and latter ones get ignored - it's like after it goes off into one of the subfunctions it never gets control back to the main function calling it.

Here's my code :

function calenderSet(){
updateDate2();
updateDate1();
updateDate3();
updateDate4();
}

and each of the subfunctions has code similar to :

function updateDate4(){
alert ("HELLO4");
var Day = window.document.calForm.dfday.value;
var Month = window.document.calForm.dfmonth.value;
var Year = window.document.calForm.dfyear.value;

var theDate = Year + Month + Day;
window.document.calForm.dfinishdate.value = theDate;
}


Is there anyway I can have my main function execute all 4 of the functions one after each other rather than just executing the first one ?

Thanks,

Russell
 
you have the alert() in each function, but only the first one works? sounds fishy.

paste the entire script here...

=========================================================
if (!succeed) try();
-jeff
 
Thanks for your reply. Yes only the first alert pops up, the other 3 functions don't get called at all.

I've included all portions of the page that this affects (it's a pretty complicated php/mysql page so i won't confuse you with the rest).

Do I need to do some special sort of return from each of the subfunctions?

Russell

function updateDate1(){
alert ("HELLO1");
var Day = window.document.calForm.esday.value;
var Month = window.document.calForm.esmonth.value;
var Year = window.document.calForm.esyear.value;

var theDate = Year + Month + Day;
window.document.calForm.estartdate.value = theDate;
}

function updateDate2(){
alert ("HELLO2");
var Day = window.document.calForm.efday.value;
var Month = window.document.calForm.efmonth.value;
var Year = window.document.calForm.efyear.value;

var theDate = Year + Month + Day;
window.document.calForm.efinishdate.value = theDate;

}

function updateDate3(){
alert ("HELLO3");
var Day = window.document.calForm.dsday.value;
var Month = window.document.calForm.dsmonth.value;
var Year = window.document.calForm.dsyear.value;

var theDate = Year + Month + Day;
window.document.calForm.dstartdate.value = theDate;
}

function updateDate4(){
alert ("HELLO4");
var Day = window.document.calForm.dfday.value;
var Month = window.document.calForm.dfmonth.value;
var Year = window.document.calForm.dfyear.value;

var theDate = Year + Month + Day;
window.document.calForm.dfinishdate.value = theDate;
}
function calenderSet(){
updateDate2();
updateDate1();
updateDate3();
updateDate4();
}

</SCRIPT>
</HEAD>

<BODY <?php if ($table == &quot;calender&quot;) echo &quot;onLoad='calenderSet();'&quot;?>>
 
using IE, check the lower-left corner of your browser for a yellow triangle that means there's script errors. if your script errors, it won't continue to the other function calls.

i simulated your page and it works fine.

make sure your form and all fields are named exactly as you call them from the script.
=========================================================
if (!succeed) try();
-jeff
 
thanks for the tip, I didn't even think to check for errors as I was re-using code from anbother page - but the form name had changed!

thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top