0

is there any way we can add space between the choice fields (Radio Buttons)?

For instance if I want to make space between Youth and Adult what would be the steps?

enter image description here

Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61
Harris
  • 593
  • 1
  • 8
  • 33

2 Answers2

0
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script>
$(function(){
  $('[title="Youth"]').closest("tr").css("display","block").css("margin-top","-15px")
  $('[title="Adult"]').closest("tr").css("display","block").css("margin-top","15px")

})
</script>

Test result:

enter image description here

Amos
  • 1,981
  • 1
  • 6
  • 12
0

To add spacing between all radio buttons of all choice fields, use below reusable function:

<script type="text/javascript">
function addSpaceBetweenRadio(){
    var tableCollection = document.querySelectorAll(&quot;table[id$='_ChoiceRadioTable']&quot;);

    for(var i = 0; i &lt; tableCollection.length; i++) {
        var tBody = tableCollection[i].children;
        var trCollection = tBody[0].children;

        for(var index = 0; index &lt; trCollection.length; index++) {
            trCollection[index].style.display = &quot;block&quot;;
            trCollection[index].style.marginBottom = &quot;10px&quot;;
        }
    }
}

_spBodyOnLoadFunctionNames.push(&quot;addSpaceBetweenRadio&quot;);

</script>

Use below steps to add this code on list form page:

  1. Go to your list form. (Example new form URL: <siteUrl>/Lists/<listName>/NewForm.aspx)
  2. Edit page
  3. Add Script Editor/Content Editor web part
  4. Add above code in web part
  5. Save/Publish list form page

Sample Output: Showing spacing between all radio buttons of all choice fields

enter image description here

Related links: Run JavaScript after page loads


No need to add reference to any external library like jQuery. Above code uses plain JavaScript.

Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61