lmooring Posted November 12, 2014 Report Share Posted November 12, 2014 I have a question about using multiple JavaScripts in a single submission form. I want to use three different JavaScripts in a single form, but as soon as I enter in more than one the other stops working. For example, in my footer I have one to concatenate email address for the acknowledgement email into a virtual field and one to do a date check to make sure one date is greater than today's date, etc. When I enter the date script the concatenation script stops working and vice versa. I have tried moving the date check script to an HTML box but it does not resolve the issue. Any suggestions or assistance would be greatly appreciated. I am not sure what I am doing wrong here. I have attached my footer scripts for convenience. <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var position1 = document.getElementsByName("InsertRecordStore_Email")[0].value; //alert("position1 :" + position1 ); //alert("position1+ :" + document.getElementsByName("InsertRecordStore_Email")[0].value); var position2 = document.getElementsByName("InsertRecordBiller_Email")[0].value; //alert("position2 :" + position2 ); //alert("position2+ :" + document.getElementsByName("InsertRecordBiller_Email")[0].value); var allpositions = position1 + ";" + position2; document.getElementById("cbParamVirtual3").value = allpositions; } document.getElementById("caspioform").onsubmit=function() { concatenate(); } </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> function checkStart() { var v_sDate = document.getElementById("InsertRecordInStoreSFA_Start").value; var v_eDate = document.getElementById("InsertRecordInStoreSFA_End").value; var sDate = new Date(v_sDate); var eDate = new Date(v_eDate); var nDate = new Date(); nDate = Date.now(); var setToday = sDate.getDate() + 1; sDate.setDate(setToday); setToday = eDate.getDate() + 1; eDate.setDate(setToday); if (sDate<nDate) { alert("SFA start date must be greater than today"); return false; } else { if (eDate<sDate) { alert("SFA end date must be greater than SFA start date"); return false; } } } document.getElementById("caspioform").onsubmit=checkStart; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Jan Posted November 13, 2014 Report Share Posted November 13, 2014 Hello Liz, I think, you can try to write the code of both functions in one, like the following code: <SCRIPT LANGUAGE="JavaScript"> function bothFunctions() { var position1 = document.getElementsByName("InsertRecordStore_Email")[0].value; //alert("position1 :" + position1 ); //alert("position1+ :" + document.getElementsByName("InsertRecordStore_Email")[0].value); var position2 = document.getElementsByName("InsertRecordBiller_Email")[0].value; //alert("position2 :" + position2 ); //alert("position2+ :" + document.getElementsByName("InsertRecordBiller_Email")[0].value); var allpositions = position1 + ";" + position2; document.getElementById("cbParamVirtual3").value = allpositions; var v_sDate = document.getElementById("InsertRecordInStoreSFA_Start").value; var v_eDate = document.getElementById("InsertRecordInStoreSFA_End").value; var sDate = new Date(v_sDate); var eDate = new Date(v_eDate); var nDate = new Date(); nDate = Date.now(); var setToday = sDate.getDate() + 1; sDate.setDate(setToday); setToday = eDate.getDate() + 1; eDate.setDate(setToday); if (sDate<nDate) { alert("SFA start date must be greater than today"); return false; } else { if (eDate<sDate) { alert("SFA end date must be greater than SFA start date"); return false; } } } document.getElementById("caspioform").onsubmit=bothFunctions; </SCRIPT> I hope, it helps. lmooring 1 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.