With reference to this post and Xiuhong Xiang solution, could I get some help changing his solution to match my needs?
I have a process where users taking care of service requests may have to report in many times during the form process and the supervisors want a report that includes the comments. I cannot do that unless I can access one field that contains all of the comments. Xiuhong has a solution that should work, however, I am not familiar enough with JavaScript to troubleshoot my own changes. Could you have a look and see if you can see what is wrong?
- q58 is the multi-line field I want all comments to populate into after every submission; variable name is "RecordedActivities";
- q60 is a read-only date field for current date (at time of each report)
- q61 is a read-only single-line field fir current user (at time of each report)
- q62 is a multi-line field for comments to report activities in (at time of each report)
I took the JavaScript Xiuhong provided in the above mentioned link and just changed the variable names and field ID numbers, but it did not result in the expected comments copied into the "RecordedActivities" field.
$(document).ready(function () {
var RecordedActivities = $('#q58 textarea').val();
//get previous comment
var RecordedActivities2 = $('#q58 textarea')[0].getAttribute('default-val');
//get previous DateofAction
var DateofAction=$('#q60 input')[0].getAttribute('default-val');
//get previous action participant
var PersonReporting=$('#q61 input')[0].getAttribute('default-val');
//get previous action
var ActionsNotes=$('#q62 input')[0].getAttribute('default-val');
//combine the information together
var currentinfo="";
if(PersonReporting!=null){
currentinfo=PersonReporting+", ";
}
if(RecordedActivities2!=null){
currentinfo=currentinfo+RecordedActivities2+", ";
}
if(DateofAction!=null){
currentinfo=currentinfo+DateofAction+", ";
}
if(ActionsNotes!=null){
currentinfo=currentinfo+ActionsNotes;
}
//append to field that display the information
if (currentinfo!=""){
RecordedActivities = RecordedActivities + '\n\n' + currentinfo;
$('#q58 textarea').val(RecordedActivities);
}
$('#q58 textarea').attr('readonly', 'True');
});