charlene Posted April 16, 2014 Report Share Posted April 16, 2014 Hi, Can anyone tell me why my three functions cannot work at the same time? Thanks! <SCRIPT LANGUAGE="JavaScript"> function myFunctionV1() { alert("Fucntion1"); var par1 = document.getElementById("EditRecordV1_OnRoadClass8").value; var par2 = document.getElementById("EditRecordV1_ExemptTruck").value; var par3 = document.getElementById("EditRecordV1_DieselFueled").value; var par4 = document.getElementsByName("EditRecordV1_MeetVMTReqt")[0].value; var par5 = document.getElementById("EditRecordV1_WillMeetVMTReqt").value; var par6 = document.getElementById("EditRecordV1_Made150Trip").value; var par7 = document.getElementById("EditRecordV1_WillMake150Trip").value; if(par1 == 'Yes' && par2 == 'Yes' && par3 == 'Yes' && par4 == 'Yes' && par5 == 'Yes' && par6 == 'Yes' && par7 == 'Yes') {document.getElementById("EditRecordV1_Eligibility").value = "Eligible";} else {document.getElementById("EditRecordV1_Eligibility").value = "NotEligible";} } function myFunctionV2() { alert("Fucntion2"); var par21 = document.getElementById("EditRecordV2_OnRoadClass8").value; var par22 = document.getElementById("EditRecordV2_ExemptTruck").value; var par23 = document.getElementById("EditRecordV2_DieselFueled").value; var par24 = document.getElementsByName("EditRecordV2_MeetVMTReqt")[0].value; var par25 = document.getElementById("EditRecordV2_WillMeetVMTReqt").value; var par26 = document.getElementById("EditRecordV2_Made150Trip").value; var par27 = document.getElementById("EditRecordV2_WillMake150Trip").value; if(par21 == 'Yes' && par22 == 'Yes' && par23 == 'Yes' && par2v4 == 'Yes' && par2v5 == 'Yes' && par2v6 == 'Yes' && par27 == 'Yes') {document.getElementById("EditRecordV2_Eligibility").value = "Eligible";} else {document.getElementById("EditRecordV2_Eligibility").value = "NotEligible";} } function myFunctionV3() { alert("Fucntion3"); var par31 = document.getElementById("EditRecordV3_OnRoadClass8").value; var par32 = document.getElementById("EditRecordV3_ExemptTruck").value; var par33 = document.getElementById("EditRecordV3_DieselFueled").value; var par34 = document.getElementsByName("EditRecordV3_MeetVMTReqt")[0].value; var par35 = document.getElementById("EditRecordV3_WillMeetVMTReqt").value; var par36 = document.getElementById("EditRecordV3_Made150Trip").value; var par37 = document.getElementById("EditRecordV3_WillMake150Trip").value; if(par31 == 'Yes' && par32 == 'Yes' && par33 == 'Yes' && par34 == 'Yes' && par35 == 'Yes' && par36 == 'Yes' && par37 == 'Yes') {document.getElementById("EditRecordV3_Eligibility").value = "Eligible";} else {document.getElementById("EditRecordV3_Eligibility").value = "NotEligible";} } document.getElementById("caspioform").onsubmit=myFunctionV1; document.getElementById("caspioform").onsubmit=myFunctionV2; document.getElementById("caspioform").onsubmit=myFunctionV3; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
MayMusic Posted April 16, 2014 Report Share Posted April 16, 2014 Try to combine all the functions together. Add the name of the field in order to the array and correct the numbers in if statement: <SCRIPT LANGUAGE="JavaScript"> var o_els = new Array("EditRecordV1_OnRoadClass8","EditRecordV1_ExemptTruck","EditRecordV1_DieselFueled","EditRecordV1_Made150Trip"); function myFunctionV1() { for (var i = 0; i < 8; i++) { if( o_els[i] == 'Yes') {document.getElementById("EditRecordV1_Eligibility").value = "Eligible";} else {document.getElementById("EditRecordV1_Eligibility").value = "NotEligible";} } for (var j = 21; j < 28; j++){ if( o_els[j] == 'Yes') {document.getElementById("EditRecordV2_Eligibility").value = "Eligible";} else {document.getElementById("EditRecordV2_Eligibility").value = "NotEligible";} } for (var k = 31; k < 38; k++){ if( o_els[k] == 'Yes') {document.getElementById("EditRecordV3_Eligibility").value = "Eligible";} else {document.getElementById("EditRecordV3_Eligibility").value = "NotEligible";} } } document.getElementById("caspioform").onsubmit=myFunctionV1; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.