Design the header and body of the table in a visually appealing format

$("input:checkbox:not(:checked)").each(function() {
  var column = "table ." + $(this).attr("name");
  $(column).hide();
});

$("input:checkbox").click(function() {
  var column = "table ." + $(this).attr("name");
  $(column).toggle();
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p style="margin-left:15px;">Additional information select below:</p>
<p style="display:inline; margin-left:15px">
  <input type="checkbox" name="vendor" />Vendor Details
  <input type="checkbox" name="ONX" />Quantity Level
  <input type="checkbox" name="Cost" />Cost Detail
  <!-- <li><input type="checkbox" name="d"  />d</li> -->

</p>

<table id="testTable" class="fixed_headers">
  <caption>
    <u><h2 >ITEM ONHAND QUANTITIES & GOODS IN TRANSACTION</h2></u>
  </caption>
  <thead>
    <tr class="header" style="background-color: #3f91bd;color:white; /* position: absolute; width: 83%; */">
      <th class="first">ITEM CODE</th>
      <th class="second">ITEM NAME</th>
      <th class="third">UNIT</th>
      <th class="headcol">ON HAND QTY</th>
      <th class="headcol">GIT</th>
      <th class="headcol">ATP</th>
      <th class="ONX" name="ONX">ONX LOW LMT</th>
      <th class="ONX" name="ONX">ONX HIGH LMT</th>
      <th class="ONX" name="ONX">ONX RE-ORDER-LEVEL</th>
      <th class="Cost">AVG COST</th>
      <th class="Cost">LAST PO PRICE</th>
      <th class="vendor" name="vendor">V_CODE</th>
      <th class="vendor">MAIN_VENDOR</th>
      <th class="vendor">VENDOR_TYPE</th>
      <th class="vendor">Vendor Mx LEAD TIM</th>
    </tr>
  </thead>
  <tbody style="display: block; border: 1px solid green; overflow-y: scroll; overflow-x: scroll; height:400px; width:850px">
    <tr>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td class="ONX">aaa</td>
      <td class="ONX">aaa</td>
      <td class="ONX">aaa</td>
      <td class="Cost">aaa</td>
      <td class="Cost">aaa</td>
      <td class="vendor">aaa</td>
      <td class="vendor">aaa</td>
      <td class="vendor">aaa</td>
      <td class="vendor">aaa</td>
    </tr>
    <tr>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td class="ONX">bbb</td>
      <td class="ONX">bbb</td>
      <td class="ONX">bbb</td>
      <td class="Cost">bbb</td>
      <td class="Cost">bbb</td>
      <td>class="vendor">bbb</td>
      <td class="vendor">bbb</td>
      <td class="vendor">bbb</td>
      <td class="vendor">bbb</td>
    </tr>
  </tbody>
</table>

The structure of the table header and body is not properly aligned. I am looking for suggestions to rectify this issue and ensure that each <tbody> column corresponds correctly with its respective <thead> column.

Answer №1

Eliminate display: block; from the inline style of the tbody

<p style="margin-left:15px;">Choose additional information below:</p>
<p style="display:inline; margin-left:15px">
  <input type="checkbox" name="vendor" />Vendor Details
  <input type="checkbox" name="ONX" />Quantity Level
  <input type="checkbox" name="Cost" />Cost Detail
  <!-- <li><input type="checkbox" name="d"  />d</li> -->
</p>

<table id="testTable" class="fixed_headers">
  <caption><u><h2 >ITEM ONHAND QUANTITIES &amp; GOODS IN TRANSACTION</h2></u>
  </caption>
  <thead>
    <tr class="header" style="background-color: #3f91bd; color: white;">
      <th class="first">ITEM CODE</th>
      <th class="second">ITEM NAME</th>
      <th class="third">UNIT</th>
      <th class="headcol">ON HAND QTY</th>
      <th class="headcol">GIT</th>
      <th class="headcol">ATP</th>
      <th class="ONX" name="ONX">ONX LOW LMT</th>
      <th class="ONX" name="ONX">ONX HIGH LMT</th>
      <th class="ONX" name="ONX">ONX RE-ORDER-LEVEL</th>
      <th class="Cost">AVG COST</th>
      <th class="Cost">LAST PO PRICE</th>
      <th class="vendor" name="vendor">V_CODE</th>
      <th class="vendor">MAIN_VENDOR</th>
      <th class="vendor">VENDOR_TYPE</th>
      <th class="vendor">Vendor Mx LEAD TIM</th>
    </tr>
  </thead>
  <tbody style="border: 1px solid green; overflow-y: scroll; overflow-x: scroll; height:400px; width:850px">
    <tr>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td>aaa</td>
      <td class="ONX">aaa</td>
      <td class="ONX">aaa</td>
      <td class="ONX">aaa</td>
      <td class="Cost">aaa</td>
      <td class="Cost">aaa</td>
      <td class="vendor">aaa</td>
      <td class="vendor">aaa</td>
      <td class="vendor">aaa</td>
      <td class="vendor">aaa</td>
    </tr>


    <tr>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td>bbb</td>
      <td class="ONX">bbb</td>
      <td class="ONX">bbb</td>
      <td class="ONX">bbb</td>
      <td class="Cost">bbb</td>
      <td class="Cost">bbb</td>
      <td class="vendor">bbb</td>
      <td class="vendor">bbb</td>
      <td class="vendor">bbb</td>
      <td class="vendor">bbb</td>
    </tr>
  </tbody>
</table>

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

Tips for incorporating images as radio buttons

Can anyone assist me in setting up a straightforward enabled/disabled radio button grouping on my form? My idea is to utilize an image of a check mark for the enabled option and an X for disabled. I would like the unselected element to appear grayed out ...

Steps to modify the look of text upon button click using jQuery and utilizing the information from a table row

Currently, I am working on a jquery code. My issue revolves around utilizing strike-through in a row that contains "101", with each number being stored in a table. For example: 1 0 1 1 1 0 1 All this data is within a table structure. My goal now i ...

Retrieve the $.data() value from within a specific selector

I'm facing an issue with the following code snippet: <img class="sth" data-number="1" src="sth.jpg" alt=""> In my project, there are multiple elements similar to this one, all differing only in the value of data-number attribute. I want to per ...

Put a cookie in place to deter users from returning to the website

Looking for a way to prevent access to my contest site once the form has been submitted. Is there a way to achieve this? Thanks in advance ...

What is the best method for obtaining a spring controller's object using AJAX?

Here is the AJAX call I am working with: var url = "UsersGroupReader.html?selectedCompanyName=" + selectedCompanyName + "&test="+Math.random(); req.onreadystatechange = processAccessGroupRequest; req.open("GET", url, true); req.send(null); function ...

Scrolling to ID or Anchor using jQuery: Automatically scrolls to the top if already at the designated section

I've been on a quest to uncover the cause and solution for this issue. Lately, I've been utilizing $("#content").animate({scrollTop:$(#elementId).offset().top-183}, 600); to achieve smooth scrolling to an ID within a <div>. The number 18 ...

The JSON response is not being returned by the static React App hosted on Microsoft

Seeking assistance from anyone who may have faced and resolved a similar issue. Our React application is deployed on Azure Static Web App and operates smoothly, but we are stuck on configuring it to return JSON instead of HTML in its responses. Within our ...

Build React separately with embedded fonts included

My React JS project currently utilizes Google Fonts through URL imports in SASS files, but now I need to create a version that can be used on a standalone local network without internet access. This means the fonts must be included within the project. I a ...

In MUI React, the opacity of the placeholder is customizable and can be easily adjusted. This allows for the placeholder to be hidden

Currently, I am facing an issue with a filled variant TextField from Mui React. I have tried to modify it using theme components, but the placeholder text becomes hidden when the field is not focused. See here for Before Focus And here for On Focus I hav ...

Include personalized headers to the 'request'

I have configured my express server to proxy my API using the following setup: // Proxy api calls app.use('/api', function (req, res) { let url = config.API_HOST + req.url req.pipe(request(url)).pipe(res) }) In this instance, confi ...

Trying to add a single value to a specific index in a JavaScript array, but it is mistakenly assigning multiple values at once

Currently tackling a matrix algorithm with an early roadblock. The array at hand is: [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] The goal is to convert it into this: [ [ 0, 0, 0 ], [ 0, 9, 0 ], [ 0, 0, 0 ] ] My plan was to alter the middle value like so ...

group items into ranges based on property of objects

I've been grappling with this issue for far too long. Can anyone provide guidance on how to tackle the following scenario using JavaScript? The dataset consists of objects representing a date and a specific length. I need to transform this list into a ...

a basic three-tier flexible design with alignment to the lower right side

I am looking to create a dynamic header that adjusts based on the height of the svg logo and available width for the navigation: layout1: If there is not enough space for all navigation buttons (a) to fit in one row next to the svg, then the nav block sh ...

What is the best way to adjust and filter an array based on a single value?

Here is an array that needs to be modified: [ {name: "test", value: "test", group: 0}, {name: "test1", value: "test2", group: 0}, {name: "test3", value: "test3", group: 1}, {name: "te ...

Broken Mui Input - Full width with attributes for minimum and maximum values

I've created a sandbox to demonstrate an issue I came across that seems unbelievable, but it's happening. Here's the link: https://codesandbox.io/s/nifty-swanson-yxj4n2?file=/NumberField.js:1075-1097 The problem is simple - when both the ht ...

Issue: The error message "articales.forEach is not a function" is indicating

app.get('/', (req, res) => { const articales = { title: 'Test Articles', createdAt: Date.now(), description: "Test Description" } res.render('index', { articales : articales }) }) <div ...

Error: Jquery unrecognized - syntax issue

How can I properly add or remove the active class from an element based on a data-filter attribute in jQuery? When I attempt to do this, I receive the following error message:Uncaught Error: Syntax error, unrecognized expression: li[data-filter=.arroz-1] $ ...

Why does my event dispatch only run once upon form submission in Svelte JS?

My code successfully fetches data and puts it in a card when new data is added to the input. However, the issue arises when more than one data entry is made - although the data gets added to the database, it does not reflect in the data list. Can anyone he ...

Sending an AJAX request to an external URL using PHP

I've been attempting to execute an ajax post request towards an external URL, and while the same request works fine in hurl.it, it doesn't seem to provide the expected output when I try it directly in the browser. When using hurl.it, I input the ...

Close any open alerts using Protractor

While using protractor and cucumber, I have encountered an issue where some tests may result in displaying an alert box. In order to handle this, I want to check for the presence of an alert box at the start of each test and close/dismiss it if it exists. ...