Jump to content

Post two scripts on one datapage


Recommended Posts

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>

Link to comment
Share on other sites

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> 

 

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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> 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...