Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to show multiple checkboxes in a series format dynamically using JS and HTML?

Posted on by 1,442

I have a below requirement to show multiple checkboxes in a format (nXn) dynamically,

Input:

Checkbox 1

Checkbox 2

Checkbox 3

Checkbox 4

Checkbox 5

Checkbox 6

Checkbox 7

-------

Output:

Checkbox 1                   Checkbox 2                 Checkbox 3               Checkbox 4          Checkbox 5

Checkbox 6                   Checkbox 7                 -------------                 -------------         -------------

-------------                    -------------                 -------------                 -------------         -------------

*This post is locked for comments

  • Suggested answer
    Nadeeja Bomiriya Profile Picture
    Nadeeja Bomiriya 6,804 on at
    RE: How to show multiple checkboxes in a series format dynamically using JS and HTML?

    Hi Arun,

    Please see below code sample.

    <html>
    <head>
        <script src="code.jquery.com/jquery-3.1.1.min.js"></script>
        <script type="text/javascript">
            var list = ["Red", "Green", "Blue", "White", "Black", "Pink", "Brown", "Purple", "Yellow"];
    
            $(document).ready(function() {
    
                $.each(list, function( index, value ) {
                  $("#parent_div").append('<input type="checkbox" name="myGroup" value="' + value + '"><label>' + value + '</label>');
                });
    
            });
    
        </script>
        <style>
    
        </style>
    </head>
    <body>
        <div id="parent_div">
        </div>
    </body>
    </html>


    Here's the output.

    Checkbox-Output.PNG

    You can now add some CSS to make it pretty :).

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: How to show multiple checkboxes in a series format dynamically using JS and HTML?

    Hi Arun Potti,

    See the links below:

    stackoverflow.com/.../creating-the-checkbox-dynamically-using-javascript

    www.htmlgoodies.com/.../display-array-data-in-an-a-tabular-format.html

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans