List filenames in 5.x response

More
1 week 4 days ago #228088 by duvemyster
Your LimeSurvey version: Version 5.3.12+220502
Own server or LimeSurvey hosting: Own server 
Survey theme/template: bootswatch
==================

In 3.x, the following lists filenames in email notification. What is the best way(s) to do this in 5.x?

1. Long Free Text Question (code: LIST):
<script type="application/javascript">
function transpose(a) {
    return Object.keys(a[0]).map(function (c) {
        return a.map(function (r) {
            return r[c];
        });
    });
}
</script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
        $('#question{QID}').hide();
        var givennames = decodeURIComponent(transpose({FILES})[1].join('~|~'));
        $("#answer{SGQ}").val(givennames).trigger('keyup');
    });
</script>

2. In notification email:
{if(FILES_filecount == '0', '', 'files:<ol><li>' + str_replace('~|~', '</li><li>', LIST) + '</li></ol>')}

Please Log in to join the conversation.

More
1 week 4 days ago #228097 by duvemyster
One solution (in 5.x) is to simply change
[1]
to
[3]
in 
var givennames = decodeURIComponent(transpose({FILES})[3].join('~|~'));
.

 

Please Log in to join the conversation.

More
1 week 1 day ago - 1 week 1 day ago #228182 by duvemyster
Is the [1], [2], or [3] position meant to change depending on whether or not 'Show title' and 'Show comments' are on or off?  There were both set to off in the survey in which the above examples were implemented,but see also bugs.limesurvey.org/view.php?id=18092 . Could that bug be the reason for the need to switch from [1] to [3], rather than the upgrade to 5.x?
Last edit: 1 week 1 day ago by duvemyster. Reason: typos

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now