lmooring Posted January 19, 2017 Report Share Posted January 19, 2017 Hi! I have multiple scripts for a submission page. When I execute the page I am only able to get one to work at a time. Not all three. I am not sure what I am doing wrong. Any help or advice would be appreciated. I have pasted the scripts below. I have all the scripts in the footer of the page. The first simply checks that the MOQ field is greater than the Inner Pack field. The second checks that cost is less than retail. They third, if the virtual check box is checked, it will copy the data from the Vendor VPN field to the Vendor Style field. <SCRIPT LANGUAGE="JavaScript"> function check() { var v_moq = parseFloat(document.getElementById("InsertRecordMOQ").value); var v_innerpack = parseFloat(document.getElementById("InsertRecordINNERPACK").value); if(v_moq<v_innerpack) { window.alert("MOQ Must Be Less Than The Inner Pack"); return false; } } document.getElementById("caspioform").onsubmit=check; </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> function check() { var v_cost = parseFloat(document.getElementById("InsertRecordCOST").value); var v_retail = parseFloat(document.getElementById("InsertRecordRETAIL").value); if(v_cost>v_retail) { window.alert("Vendor Cost must be less than Retail"); return false; } } document.getElementById("caspioform").onsubmit=check; </SCRIPT> <script> function f_vendorstyle() { if(document.getElementById('cbParamVirtual1').checked) { document.getElementById('InsertRecordVENDORSTYLE').value=document.getElementById('InsertRecordVENDORVPN').value; } else { document.getElementById('InsertRecordVENDORSTYLE').value=""; } } document.getElementById('cbParamVirtual1').onclick= f_vendorstyle; </script> Quote Link to comment Share on other sites More sharing options...
TWIRED Posted January 20, 2017 Report Share Posted January 20, 2017 sorry re-read your post, this might be the answer. http://stackoverflow.com/questions/11806253/onsubmit-multiple-javascript-functions http://stackoverflow.com/questions/16250915/how-to-call-two-functions-on-a-form-submit Quote Link to comment Share on other sites More sharing options...
lmooring Posted January 25, 2017 Author Report Share Posted January 25, 2017 Hi Twired, I don't know that I am javascript savvy enough to get this into my form. I updated the scripts above to distinct function names, so I have checkCOST and checkMOQ. Based on my understanding of the articles you gave I added :<form onsubmit="return ((checkCOST() & checkMOQ()) == 1)"> to my footer but I am not able to get anything to work. I did determine that the third script "f_vendorstyle" was acting correctly and was not required in the onsubmit validation. Any additional assistance or guidance would be most appreciated. 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.