wgalliance Posted June 24, 2016 Report Share Posted June 24, 2016 I have two scripts I'd like to run on the same Submission form. The first one (Concatenate) combines several fields. This script has worked fine up until I added the second script. The second script needs to look for a value in the Application Type field and if the value is "Partial Application" then it changes a field to "not required" if the value is "full application" then it changes the field "Incomplete". Once I added the second script, neither of them work. Could someone help me out with how this should work? <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var position1 = document.getElementById("InsertRecordCampaignYear").value = "2017 CFC"; var position2 = document.getElementById("InsertRecordFedAcronym").value = "[@authfield:CharityDetail_Fed_Acronym]"; var position3 = document.getElementById("InsertRecordEIN").value = "[@authfield:CharityDetail_EIN]"; var allpositions = position1 + " " + position2 + " " + "-" + " " + position3; document.getElementById("InsertRecordCampaignName_EIN").value = allpositions; { {document.getElementById("caspioform").onsubmit=concatenate; } document.getElementById("caspioform").onsubmit = function(){ if (document.getElementById("InsertRecordApplicationType]").value == "Partial Application"){ document.getElementById("InsertRecordTask_DescriptionofServices").value = "Not Required"; } else { document.getElementById("InsertRecordTask_DescriptionofServices").value = "Incomplete"; } } </SCRIPT> Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 24, 2016 Report Share Posted June 24, 2016 Change your code to below and see if that helps <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var position1 = document.getElementById("InsertRecordCampaignYear").value = "2017 CFC"; var position2 = document.getElementById("InsertRecordFedAcronym").value = "[@authfield:CharityDetail_Fed_Acronym]"; var position3 = document.getElementById("InsertRecordEIN").value = "[@authfield:CharityDetail_EIN]"; var allpositions = position1 + " " + position2 + " " + "-" + " " + position3; document.getElementById("InsertRecordCampaignName_EIN").value = allpositions; } function f_change(){ if (document.getElementById("InsertRecordApplicationType]").value == "Partial Application"){ document.getElementById("InsertRecordTask_DescriptionofServices").value = "Not Required"; } else { document.getElementById("InsertRecordTask_DescriptionofServices").value = "Incomplete"; } } document.getElementById("caspioform").onsubmit=concatenate; document.getElementById("caspioform").onsubmit=f_change; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
wgalliance Posted July 5, 2016 Author Report Share Posted July 5, 2016 Hmmm, I tested it and it wouldn't work. If I remove the f_change function then it will create a new submission, otherwise I get the message "Values in one or more field are invalid". The field ApplicationType I have it receiving an authentication field on load. Could it be that I need to write the code in a different way? if ([@authfield:CharityDetail_FullApp].value == "Partial Application"){ document.getElementById("InsertRecordTask_DescriptionofServices").value = "Not Required"; } else { document.getElementById("InsertRecordTask_DescriptionofServices").value = "Incomplete"; } I tried the above and it still would not work. I will message you the login credentials to look at the page. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 5, 2016 Report Share Posted July 5, 2016 Try the code below and let me know if that helps <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var position1 = document.getElementById("InsertRecordCampaignYear").value = "2017 CFC"; var position2 = document.getElementById("InsertRecordFedAcronym").value = "[@authfield:CharityDetail_Fed_Acronym]"; var position3 = document.getElementById("InsertRecordEIN").value = "[@authfield:CharityDetail_EIN]"; var allpositions = position1 + " " + position2 + " " + "-" + " " + position3; document.getElementById("InsertRecordCampaignName_EIN").value = allpositions; } function f_change(){ if (document.getElementById("InsertRecordApplicationType]").value == "Partial Application"){ document.getElementById("InsertRecordTask_DescriptionofServices").value = "Not Required"; } else { document.getElementById("InsertRecordTask_DescriptionofServices").value = "Incomplete"; } } function f_run(){ concatenate(); f_change(); } document.getElementById("caspioform").onsubmit=f_run; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
wgalliance Posted July 5, 2016 Author Report Share Posted July 5, 2016 Thanks, I tried that one as well, its still returning an error message on the CampaignName_EIN field which is the result of the concatenate function. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 5, 2016 Report Share Posted July 5, 2016 Is it possible to provide me the URL to the page? Quote Link to comment Share on other sites More sharing options...
wgalliance Posted July 5, 2016 Author Report Share Posted July 5, 2016 I sent you a message with the URL and log in info. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 5, 2016 Report Share Posted July 5, 2016 You have a field in your page called "CampaignName_EIN" which is holding concatenated value and it is display only. If you want to have access to this field to save the value in it should not be Display only so you need to either change it to text field or hidden. Quote Link to comment Share on other sites More sharing options...
wgalliance Posted July 8, 2016 Author Report Share Posted July 8, 2016 Thanks, that solved the error message. The second script f_change is still not working. I am able to create a new submission but still not able to change the Task_DescriptionofServices to either Incomplete or Not Required. the field that it is searching on is receiving data from an authentication field. Would this change the code? 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.