Combining the contents of one HTML table with Bootstrap styling into another Bootstrap table

Check out the Bootstrap UI I created in the screenshot below:
https://i.sstatic.net/NnZzI.png
Here's the code. When a user clicks on the accept button in the new orders table, I want 'food 1' to move to the 'accepted' table. My current code doesn't seem to be working. How can I fix this?

Javascript:
function append() {
        // Code...
        if (!('#btnOne').onclick) {
            var htmlrows = "";
            var htmltablestart = '<table class="table table-hover borderless">';
            htmlrows = htmlrows + '<tr><td>' + foodOne + '</td><td class="pull-right"> <button type="button" class="btn btn-primary" onclick="appendComplete();" id="btnThree">Completed</button> </td><td></tr>';
            var htmltableend = '</table>';
            var htmlTable = htmltablestart + htmlrows + htmltableend;
            ('#acceptedOrdrDiv').append(htmlTable);
            alert('you have accepted the order');
        } else {
            alert('you have not accepted the order');
        }
    }

    function appendComplete() {
        // Code...
        if (!('#btnThree').onclick) {
            var htmlrows = "";
            var htmltablestart = '<table class="table table-hover borderless">';
            htmlrows = htmlrows + '<tr><td>' + foodOne + '</td></tr>';
            var htmltableend = '</table>';
            var htmlTable = htmltablestart + htmlrows + htmltableend;
            ('#completedOrdrDiv').append(htmlTable);
            alert('you have completed the order');
        } else {
            alert('you have not completed the order');
        }
    }  

In addition, I would like it so that when an accepted order is clicked on the 'Accept' button, it gets removed from the 'new order' table.

Answer №1

Here is the code snippet for handling accepted orders:

<div id="acceptedOrdrDiv" class="panel-body" style="overflow-y: auto; height: 90%;">
    <table class="table table-hover borderless accepted-orders">
    </table>
</div>

When a user clicks on the primary button, the following JQuery script will be triggered:

$('.btn.btn-primary').click(function () {
    var text = $(this).parent().parent().children().filter(':first-child');
    var thisTr = text.parent();
    console.log($('.table.accepted-orders'));
    $('.table.accepted-orders').append('<tr><td>'+text.text()+'</td><td class="pull-right"><button type="button" class="btn btn-primary">Completed</button></td>');
    thisTr.remove();
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it necessary to call cancelAnimationFrame before the next requestAnimationFrame?

Within my React timer application, I am unsure if I need to always call cancelAnimationFrame before the next requestAnimationFrame in the animate method. I have come across conflicting information - one source mentioned that if multiple requestAnimationFr ...

Testing for expressjs 4 using Mocha revealed unexpected behavior when attempting to spy on a function called within a promise. Despite setting up the

I have encountered a situation with some test cases structured like this: it('does stuff', function(done) { somePromise.then(function () { expect(someSpy).to.have.been.called done() }) }) When the assertion in a test case fails, it ...

Issue with generating WebGL shaders

As I embark on creating a basic application in WebGl and JavaScript following online tutorials, I encountered a peculiar issue while working on some fundamental shaders. The function responsible for generating the shader program presents itself as follows: ...

Substituting text in a document by utilizing two separate arrays: one holding the original text to be found and another storing the corresponding text for

I am facing a challenge with replacing specific text strings in a file. I have two arrays - one containing the strings that need to be located and replaced, and the other containing the replacement strings. fs.readFile("./fileName.L5X", "utf8", function( ...

Could a Three.js mesh with fewer morph targets be influenced by another mesh with a greater number of morph targets?

It's quite strange that an Object3D with fewer morph targets can be influenced by another one with more morph targets. To demonstrate this issue, I replicated the error here by introducing a cube with 4 morph targets into the Three.js official exampl ...

Printing 'undefined' to the console after making an API call with Vue

After authenticating and fetching data from a 3rd party API in my Laravel Controller, I'm encountering an issue where 'undefined' is being logged in the console instead of the actual data that I want to store in a Vue component. I've t ...

Illumination modeling

After importing a model using OBJMTLLoader, it is automatically configured as a MeshLambertMaterial, causing the textures to appear darker and not in full color. I am struggling to adjust the lighting in the scene to correct this issue. I have attempted t ...

The Bootstrap Row emerges from the shadow of the margin

Recently, I started diving into the world of Bootstrap. While playing around with some code to create rows resembling a table, I noticed an issue. When I loaded the code in my browser, the margins of the rows appeared off-screen. Take a look at this simple ...

What are some ways to implement Node.js within Netsuite?

Recently, I've been exploring Netsuite and I'm curious to learn about the feasibility of integrating Node.js or npm modules into a SuiteScript or Suitelet. Is it possible? I have a specific aim in mind - to utilize some npm modules within Netsui ...

Having trouble implementing new controllers in AngularJS UI-Router for nested states?

I'm currently facing an issue with nested states in the ui-router. My task involves rendering a page that includes regions, countries, and individuals per country. In the index.html file, there are three regions represented as links: EMEA, APAC, and ...

Guide on generating a request through iteration using Javascript

I'm currently working on a request that involves multiple methods, and I want to streamline the code by using an enum to iterate through and construct the request. However, my attempt at doing this has resulted in unexpected outcomes. The original co ...

Image not aligning to center - email

Struggling to center align an image at the top of an email due to code that hides it when the browser is larger than 520px. Is there a way to exempt this specific image and keep it centered? .mobile { display: none !important; font-size 0 !importa ...

The function 'ChartModule' cannot be called, as function calls are not supported

I am encountering a similar problem as discussed in Angular 2 - AOT - Calling function 'ChartModule', function calls not supported ERROR: Error encountered while resolving symbol values statically. Trying to call function 'ChartModule&apos ...

creating grunt shortcuts with specified option values

Is it possible to create custom aliases in Grunt, similar to npm or bash? According to the Grunt documentation, you can define a sequence of tasks (even if it's just one). Instead of calling it "aliasing", I believe it should be referred to as "chaini ...

What is the best way to preserve search form results while submitting a different form on the same page?

Initially, a list of businesses stored in a database is displayed. Users can search for businesses by industry or state using a form. The search results include an option to move the businesses to different tables. After submitting the form to relocate a b ...

Bootstrap 5 NavBar Toggle hamburger Menu not displaying menu items

I attempted to create a navigation bar using the navbar instructions in Bootstrap 5. I included a Toggle hamburger Menu and linked it to the list that should be displayed. However, when I decrease the screen size, the Toggle feature does not function as ex ...

Tips for accessing the following element within an array using a for loop with the syntax for (let obj of objects)

Is there a way to access the next element in an array while iterating through it? for (let item of list) { // accessing the item at index + 1 } Although I am aware that I could use a traditional for loop, I would rather stick with this syntax. for (i ...

selecting arrays within arrays according to their date values

With an array of 273 arrays, each containing data about a regular season NFL football game, I am looking to categorize the games by week. In total, there are 17 weeks in the NFL season that I want to represent using separate arrays. The format of my array ...

Encountering a problem while attempting to concurrently execute front and backend processes through the npm run both command

npm run both npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. > <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfd6d1d0cbdaddd0d0d4ff8f918e918f">[email protected]</a&g ...

converting the names of files in a specific directory to a JavaScript array

Currently working on a local HTML document and trying to navigate through a folder, gathering all the file names and storing them in a JavaScript array Let's say I have a folder named Videos with files like: - VideoA.mp4 - VideoB.mp4 How can I cre ...