# Programmatic checkbox entries

**URL:** <https://discourse.nodered.org/t/programmatic-checkbox-entries/73731>\
**Category:** Developing Nodes\
**Created:** [15 January 2023 23:31 UTC](https://discourse.nodered.org/t/programmatic-checkbox-entries/73731 "2023-01-15T23:31:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.willing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chris.willing/32/76579_2.png) [@chris.willing](https://discourse.nodered.org/u/chris.willing)\
**Post date:** [15 January 2023 23:31 UTC](https://discourse.nodered.org/t/programmatic-checkbox-entries/73731/1 "2023-01-15T23:31:02Z")

</div>

There was an interesting example given [here](https://discourse.nodered.org/t/how-to-get-values-of-node-configuration-checkboxes/62202) (thanks @marcus-j-davies), showing how to create varying numbers of checkbox items when configuring a node. That thread is closed, therefore this new question.

I'd like to do something like the example that but the problem is that it requires the number of checkbox items to be known beforehand (3 in the example). However in my use case the number of items is not known beforehand and will be discovered at runtime. I can obtain the number of items and associated item data at _oneditprepare_ in the javascript section but (based on that information) could anyone outline how to then dynamically generate the correct number of form-row entries in the html section?

That is to ask - if I find at run time that I need 4 checkbox items, how to generate 4 form-row divs; if I find I need 7 checkbox items, how to generate 7 form-row divs etc. ?

Thanks for any help,  
chris

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 January 2023 00:18 UTC](https://discourse.nodered.org/t/programmatic-checkbox-entries/73731/2 "2023-01-16T00:18:05Z")

</div>

The trick is probably to understand that you have access to jQuery which makes making dynamic UI elements fairly easy. So you can just loop through whatever is defining the number of checkboxes and use jQuery to create the inputs.

---

<div class="post-metadata">

**Author:** ![chris.willing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chris.willing/32/76579_2.png) [@chris.willing](https://discourse.nodered.org/u/chris.willing)\
**Post date:** [16 January 2023 03:44 UTC](https://discourse.nodered.org/t/programmatic-checkbox-entries/73731/3 "2023-01-16T03:44:35Z")

</div>

Thanks for the pointer.

I repurposed a code example in [this thread](https://discourse.nodered.org/t/input-type-checkbox/43511) and it works just fine (thanks @Steve-Mcl). I have some formatting details to sort out now but that's a different problem.

Thanks again,  
chris

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 January 2023 03:45 UTC](https://discourse.nodered.org/t/programmatic-checkbox-entries/73731/4 "2023-01-30T03:45:05Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
