<script>
    $(document).ready(function() {
        $('#submit_blueprint_tools_from').on('submit', function(e) {
            e.preventDefault(); // Prevent the form from submitting via the browser
            var formData = new FormData(this);
            $.ajax({
                url: '<?php echo base_url(); ?>/admin/course/upload_bundle_blueprint_form_data',
                type: 'POST',
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                success: function(response) {
                    $("#bundle_certified_from").load(window.location.href + " #bundle_certified_from");
                    swal({
                        title: "Done!",
                        text: "Data Successfully Added",
                        icon: "success",
                    });
                    $('#blueprint_from_modal').modal('hide');
                    $('#blueprint_from_title').val('');
                    $('#blueprint_from_content').val('');
                    $('#blueprint_from_image').val('');
                    $('button[type="submit"]').html('Save');
                    $('button[type="submit"]').attr('disabled', false);
                },
                error: function(e) {
                    console.log(e.responseText)
                }
            });
        });
    }); 

    function addRowForWhyYouGet() {
        var table = document.getElementById("dynamic-table-for-why-you-get");
        var row = table.insertRow(table.rows.length);

        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);
        var cell3 = row.insertCell(2);

        cell1.innerHTML = '<input type="text" placeholder="Enter Qns *" class="form-control" name="benifit_qns[]" required>';
        cell2.innerHTML = '<input type="text" placeholder="Enter Ans *" class="form-control" name="benifit_ans[]" required>';
        cell3.innerHTML = '<button type="button" class="btn btn-danger" onclick="deleteRowForWhyYouGet(this)">Delete</button>';
    }

    function deleteRowForWhyYouGet(button) {
        var row = button.parentNode.parentNode;
        row.parentNode.removeChild(row);
    }

    // function addRowForFaq() {
    //     var table = document.getElementById("dynamic-table-for-faq");
    //     var row = table.insertRow(table.rows.length);

    //     var cell1 = row.insertCell(0);
    //     var cell2 = row.insertCell(1);
    //     var cell3 = row.insertCell(2);

    //     cell1.innerHTML = '<input type="text" placeholder="Enter Qns *" class="form-control" name="faq_qns[]" required>';
    //     cell2.innerHTML = '<input type="text" placeholder="Enter Ans *" class="form-control" name="faq_ans[]" required>';
    //     cell3.innerHTML = '<button type="button" class="btn btn-danger" onclick="deleteRowForFaq(this)">Delete</button>';
    // }

    // function deleteRowForFaq(button) {
    //     var row = button.parentNode.parentNode;
    //     row.parentNode.removeChild(row);
    // }

    

    function addRowForWhatYouGet() {
        var table = document.getElementById("dynamic-table-for-what-you-getting");
        var row = table.insertRow(table.rows.length);

        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);

        cell1.innerHTML = '<input type="text" placeholder="Enter Content *" class="form-control" name="what_you_get[]" required>';
        cell2.innerHTML = '<button type="button" class="btn btn-danger" onclick="deleteRowForWhatYouGet(this)">Delete</button>';
    }

    function deleteRowForWhatYouGet(button) {
        var row = button.parentNode.parentNode;
        row.parentNode.removeChild(row);
    }
</script>