Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

List filenames in 5.x response

  • duvemyster
  • duvemyster's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 11 months ago #228088 by duvemyster
List filenames in 5.x response was created 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):
Code:
<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:
Code:
{if(FILES_filecount == '0', '', 'files:<ol><li>' + str_replace('~|~', '</li><li>', LIST) + '</li></ol>')}

Please Log in to join the conversation.

  • duvemyster
  • duvemyster's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 11 months ago #228097 by duvemyster
Replied by duvemyster on topic List filenames in 5.x response
One solution (in 5.x) is to simply change
Code:
[1]
to
Code:
[3]
in 
Code:
var givennames = decodeURIComponent(transpose({FILES})[3].join('~|~'));
.

 

Please Log in to join the conversation.

  • duvemyster
  • duvemyster's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 11 months ago - 1 year 11 months ago #228182 by duvemyster
Replied by duvemyster on topic List filenames in 5.x response
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 [url] bugs.limesurvey.org/view.php?id=18092 [/url]. 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 year 11 months ago by duvemyster. Reason: typos

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose