0

Is there a way to add static text into a list form (new, display and edit) ? For example, put some field under a text "Part One", and place a "Part Two" for the next last fields.

Part One

Column name           Field1
Column name           Field2
Column name           Field3

Part Two

Column name           Field4
Column name           Field5

Thank you for your ideas.

PS : SP2016 classic on-prem

2
  • If you are using classic experience in 2016, you can edit the page with custom Javascript: just open random item > Edit Page > Add a "Content Editor" web part to the page > (Click on the link to add new content, if you are using a web part page.) > Click on the Edit Source button in the ribbon. > Paste your JavaScript code in the HTML source > Apply and save the page > kalmstrom.com/Tips/SharePoint-Online-Course/…
    – Popkornak
    Commented Jun 26, 2023 at 10:51
  • Thank you. I already kno how to use script or content editor. But I'm not very good at scripting or programming, so I'm looking for a more detailed solution.
    – AnthonyS
    Commented Jul 7, 2023 at 14:20

1 Answer 1

0

As a quick and dirty way you can use Script Editor webpart and jQuery:

  1. Open new\edit\display list form, click Edit Page
  2. Add Script Editor webpart, preferably below your "main" form webpart
  3. Add one of the following lines to the Script Editor web part, depending on whether you want to find fields (that will be preceded by your captions) by display name or by internal.
  • on New and Edit forms, by internal name:
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script language="javascript" type="text/javascript">
  var partOne = 'Field1InternalName'
  var partTwo = 'Field4InternalName'
  _spBodyOnLoadFunctionNames.push("BodyOnLoad");
  function BodyOnLoad(){
    jQuery("input[id^='" + partOne + "']").closest("tr").before("<b>Part One</b><br/>");
    jQuery("input[id^='" + partTwo + "']").closest("tr").before("<b>Part Two</b><br/>");
  }
</script>
  • on New and Edit forms, by display name:
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script language="javascript" type="text/javascript">
var partOne = 'Field1DisplayName'
var partTwo = 'Field4DisplayName'

_spBodyOnLoadFunctionNames.push("BodyOnLoad");
function BodyOnLoad(){
  jQuery("td.ms-formlabel:has(span:has(nobr:contains('" + partOne + "')))").closest("tr").before("<b>Part One</b><br/>");
  jQuery("td.ms-formlabel:has(span:has(nobr:contains('" + partTwo + "')))").closest("tr").before("<b>Part Two</b><br/>");
}
</script>
  • on Display form, by internal name:
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script language="javascript" type="text/javascript">
  var partOne = 'Field1InternalName'
  var partTwo = 'Field4InternalName'
  
  _spBodyOnLoadFunctionNames.push("BodyOnLoad");
  function BodyOnLoad(){
    jQuery("a[name='SPBookmark_" + partOne + "']").closest("tr").before("<b>Part One</b><br/>");
    jQuery("a[name='SPBookmark_" + partTwo + "']").closest("tr").before("<b>Part Two</b><br/>");
  }
</script>
  • on Display form, by display name:
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script language="javascript" type="text/javascript">
var partOne = 'Field1DisplayName'
var partTwo = 'Field4DisplayName'

_spBodyOnLoadFunctionNames.push("BodyOnLoad");
function BodyOnLoad(){
  jQuery("td.ms-formlabel:has(span:contains('" + partOne + "'))").closest("tr").before("<b>Part One</b><br/>");
  jQuery("td.ms-formlabel:has(span:contains('" + partTwo + "'))").closest("tr").before("<b>Part Two</b><br/>");
}
</script>
1
  • Thnak you very much for your help ! I'll try this as soon as possible
    – AnthonyS
    Commented Jul 7, 2023 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.