JSFiddle - React, Tailwind, and code Playground

JavaScript

// The following is what is in my .js file: (see the bottom of this script for part of what is in my PHP file)

var f = document.createElement("form");
f.setAttribute('method', "get");
f.setAttribute('action', "index.php");

var Category = (function () {
    var categoryCount = 0;
    
    function elem(tag) { // shortcut
        return document.createElement(tag);
    }
    function text(str) { // shortcut
        return document.createTextNode(str);
    }
    function Category(node) {
        var self = this;
        this.categoryId = ++categoryCount;
        // make add button
        this.addButton = elem('button');
        this.addButton.appendChild(text('Add Textbox'));
        this.addButton.addEventListener('click', function () {
            self.addTextbox();
        });
        // make wrapper
        this.wrapper = elem('section');
        this.wrapper.setAttribute('id', 'cat'+this.categoryId);
        this.wrapper.appendChild(this.addButton);
        // make textboxes
        this.textboxes = [];
        this.addTextbox();
        // append to document
        if (node) {
            this.append(node);
        }
        
    }
    Category.prototype.addTextbox = function () {
        var e = document.createElement("input");
        e.setAttribute('name', 'cat-'+this.categoryId+'-textbox[]');
        f.appendChild(e); // this is where each textbox is supposed to be added to the form...
        this.textboxes.push(e);
        this.wrapper.insertBefore(e, this.addButton);
    };
    Category.prototype.append = function (node) {
        return node.appendChild(this.wrapper);
    };
    return Category;
        
}());

var s = document.createElement("input"); //input element, Submit button
s.setAttribute('type',"submit");
s.setAttribute('value',"Submit");
f.appendChild(s);

//var cat1 = new Category(document.body);
//var cat2 = new Category(document.body);
//document.getElementsByTagName('body')[0].appendChild(f);


/* the above comment is only for you to...