I have a number between 1 and 100 stored in a JavaScript variable:
var number_units = 3;`
I want to take the value of number_units and create this HTML selection field that many times:
var html = '<select class="form-control input-sm">'+
'<option value="1">1</option>'+
'<option value="2">2</option>'+
'<option value="3">3</option>'+
'<option value="4">4</option>'+
'</select>';
If number_units is 3, my code should create the selection field 3 times.
I then save the form that these selection fields are part of using AJAX to a PHP backend. So I need to figure out how to get all the selection values when my AJAX post is made and create a separate database entry for each value.
I need help with the JavaScript to create the selection field number_units times.
I can probably store in a hidden form field the count of selection fields and then give them a name with an increment number and iterate to that number in my back end to save each one. How would I go on from here?