Replace ; with line feed

Home Forums Classic DFFS Replace ; with line feed

Viewing 4 reply threads
  • Author
    Posts
    • #23698
      Phil Grant
      Participant

        Hi,
        I have a field that contains multiple entries selected by checkboxes that currently display one after the other separated by “;” and I would like to display them as a list of separate items.

        Is it possible to do a character replace on the “;” for a new line feed?

        I have

        Item1;Item2;Item3;Item4

        I would like

        Item1
        Item2
        Item3
        Item4
      • #23700
        Alexander Bautz
        Keymaster

          I guess this is in DispForm? – if so, you can add something like this to your Custom JS:

          var raw = getFieldValue("YourFieldName");
          jQuery("#dffs_YourFieldName td.ms-formbody").html(raw.split(";").join("<br>"));

          Replace “YourFieldName” with your field name.

          Alexander

          • #23702
            Phil Grant
            Participant

              Thanks, I’ll give it a go, yes it is in the display form.

          • #23715
            Phil Grant
            Participant

              Alexander,
              I tried the JS but it doesn’t work, I’m guessing that it’s because of the spaces in the field name? I tried various ways of writing it including escape characters in front of the spaces, underscores instead of spaces but nothing worked.

              Hopefully this is easy when you know the language, this is what I have: –

              
              
              var raw = getFieldValue("Projects also affected");
              jQuery("#dffs_Projects also affected td.ms-formbody").html(raw.split(";").join("<br>"));
            • #23725
              Alexander Bautz
              Keymaster

                You must use the FieldInternalName – look at the Fields tab in DFFS backend to find the correct name.

                Alexander

              • #23729
                Phil Grant
                Participant

                  LoL, that’s the only thing I didn’t try because you usually write FeildInternalName in the code when you want us to use it, this time I though YourFieldName specifically meant not to use the FIN.

                  It works now thanks.

              Viewing 4 reply threads
              • You must be logged in to reply to this topic.