JSFiddle - React, Tailwind, and code Playground

by mbeasley183

HTML

<select id="selectBox">
    <option value="">Select a #</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="22">22</option>
</select>

<div id="container"></div>

JavaScript

$('#selectBox').on('change',function() {
    // when the box is changed, get the value associated with
    // the selected value
    var count = parseInt($('#selectBox').val());
    
    // make sure the selected value is a number and if it is...
    if (!isNaN(count)) {
        
        // ... then loop through the following code block 
        // n times, where n is the value of the select box
        for (var i = 0; i < count; i++) {
            
            // this is just a place holder for the demo, but 
            // put whatever you want here
            $('#container').append("hi");            
        }
        
    }
});