Add More Fields in Bootstrap Studio

Hello all,

How to create a form page in Bootstrap Studio where on the form page the user can add additional fields if the data to be input is more than one, so on the form page the user can click on the "Add More" button according to his needs, or is there a template for this kind of purpose?.



You'd have to use JavaScript to do DOM manipulation where an Add More button injects additional selectbox options or other form elements. That all depends on what you're really trying to accomplish. So I did a search and found this

Then I jQuery'd it up some so you can see a working version of it for a preview use

function addFields(){
    // Number of inputs to create
    var number = parseInt($("#member").val());
    // Max Number of inputs to create
    var mN = parseInt($("#member").attr("max"));
    // Container <div> where dynamic content will be placed
    var container = $("#container");
    // Create Array for Member inputs
    var members = [];
    // Check if exceed Max allowed
    if (number > mN) {
        alert("Please enter no more than 10");
    // Clear previous contents of the container

    for (i=0;i<number;i++){
        // Loop through and stuff into Array the number of Member inputs created
        members.push("<div class='form-group'>");
        members.push("<label for='member" + (i+1) + "' class='members'>Member " + (i+1) + ":</label> ");
        members.push("<input id='member" + (i+1) + "' " + " name='member"+ (i+1) +"' type='text' value=''>");
    // Join an Append Array of Member inputs


And my HTML to go with that changes

    <div class="form-group">
        <label for="member">Number of members: (max. 10)</label><input type="number" name="member" max="10" required class="form-control" min="0" id="member" />
    <div id="container"></div>

Just a working example for what can be done, and there's all kinds of internet searches you can do to find JS code that will be closer to something your looking for.