How to deal with Multiple functions?

I am stumped at how to handle this. So i am just going to throw the question out here and see if someone can help me.

I have three functions in the JSHEADER of a form. If i call each of these on its own from a button they work fine.

However, I want to call them in order and if one function completes without an error it should proceed to the next and if they all pass without error, the form should submit.

Do these all need rewritten to do that?

function validateSelections() {

var selectFields = document.forms[0].elements;

var selections = new Array();

var fieldNamePrefix = “D”;

for (var i=1; i<=10; ++i) {

var field = selectFields[fieldNamePrefix + i];

if (field.selectedIndex>0 && selections[field.options[field.selectedIndex].text]) {

alert(“You cannot select the same item twice”);

field.focus();

return false;

}

else {

selections[field.options[field.selectedIndex].text] = 1;

}

}

return true;

}

function validateSelctionsMade() {

var myindex=document.forms[0].D1.selectedIndex;

if (myindex==0) {

alert(“\nYou must make at least one selection from the drop-down menu.”);

document.forms[0].D1.focus();

}

else {menu_selection=document.forms[0].D1.options[myindex].value;

return true;

}

}

function validateQTYSelections() {

var selectFields = document.forms[0].elements;

var selections = ;

//you could also use var selections = new Array();

//first range of fields

var fieldNamePrefix = “D”;

//second range of fields

var fieldNamePrefix2 = “Q”;

for (var i=1; i<=10; ++i) {

var field = selectFields[fieldNamePrefix + i];

var field2 = selectFields[fieldNamePrefix2+ i];

if (field.selectedIndex>1 && field2.selectedIndex<1) {

alert(“You must select a quantity”);

field2.focus();

return false;

}

else {selections[field.options[field.selectedIndex].text] = 1;

}

}

return true;

}

Subject: How to deal with Multiple functions?

thanks…appreciate you taking time out… that works…

Subject: How to deal with Multiple functions?

write yr 3 functions,

Write another function that calls these 3 as per yr requirement.

Subject: How to deal with Multiple functions?

Try something like this:

if (validateSelections()) {

if (validateSelctionsMade()) {

    if (validateQTYSelections()) {

        doc.submit();

    }

}

}