[Solved] String format


This piece of code shows the first 5 digits of the string;

 [question(“value”), id=”6″,stringformat=”%.5s”)]

But, how do I show the last 5 digits in the string?


Alex Walker asked

    Best answer

    Holly 2.17K Rep.

    Hey Alex,

    Thank you for using Community! 🙂

    There isn’t a built in way to do this but we do have a workaround for you if you are familiar with scripting.

    Click here to download an example survey to your account.

    On the page following your question that you want the 5 character string of, create a text element and go to the source code by clicking the 3 dots and then the icon that looks like a piece of paper with two arrows facing outwards. Next paste the following:

    <span class=”placeholder”>This is my placeholder text that will turn into the string. </span>

    Next click Add Action: JavaScript and paste the following:

    $(document).ready(function () {
    var string = ‘[question(“value”), id=”2″]’;

    $(‘.placeholder’).text(string.substr((string.length > 5) ? string.length – 5 : 0));

    Once you have that pasted, replace the 2 with the ID of the question you’d like the string to be created from. Here’s an article on finding question IDs.

    Now, once your run through the survey you should see that Placeholder text change to the last five characters of your string like in this survey.

    I hope that helps!


    Holly White, Survey Fire Dancer

    Holly answered

      You wonderful people – works perfectly!

      Alex Walker answered


        Question stats

        • Active
        • Views12014 times
        • Answers2 answers
        • Followers0 followers