Basically, the user clicks on the “choose” button to choose an item and it will link them to a different page with a list of items, whenever the user clicks the “add” button of an item it will link them back to the previous page but the “choose” button should be hidden and the corresponding text and image of the item are placed instead of it.
I tried to use jquery to hide the button and show the others when I click a button from another page but it’s not working.
Here’s my main HTML
<html>
<body>
<div class="block__partlist">
<table class="xs-col-12">
<thead>
<tr>
<th class="th__component">Component</th>
<th></th>
<th class="th__Selection" colspan="2">Selection</th>
<th class="th__base">Base</th>
<th class="th__price">Price</th>
</tr>
</thead>
<tbody>
<tr class="tr__product">
<td class="td__component">
<a href="/pageOne.html">Item1</a>
</td>
<td class="td__placement--empty"></td>
<td class="td__image" style="display: none;"></td>
<td class="td__name" style="display: none;"></td>
<td class="td__base" style="display: none;"></td>
<td class="td__price" style="display: none;"></td>
<td class="td__addComponent" colspan="11">
<a href="/pageOne.html" class="button__add">
Choose An Item
</a>
</td>
</tr>
<tr class="tr__product">
<td class="td__component">
<a href="/PageTwo.html">Item2</a>
</td>
<td class="td__placement--empty"></td>
<td class="td__image" style="display: none;"></td>
<td class="td__name" style="display: none;"></td>
<td class="td__base" style="display: none;"></td>
<td class="td__price" style="display: none;"></td>
<td class="td__addComponent" colspan="11">
<a href="/PageTwo.html" class="button__add">
Choose An Item
</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Second HTML page
<html>
<body>
<table class="productList--detailed" id="paginated_table" role="grid">
<thead>
<tr role="row" class="tablesorter-headerRow">
<th class="th--sortable tablesorter-header tablesorter-headerUnSorted th--unsorted" data-column="1" tabindex="0" scope="col" role="columnheader" aria-disabled="false" aria-controls="paginated_table" unselectable="on" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort" style="user-select: none;">
<div class="tablesorter-header-inner">
<p>Product</p>
</div>
</th>
<th class="th--sortable tablesorter-header tablesorter-headerUnSorted th--unsorted" data-column="7" tabindex="0" scope="col" role="columnheader" aria-disabled="false" aria-controls="paginated_table" unselectable="on" aria-sort="none" aria-label="Price: No sort applied, activate to apply an ascending sort" style="user-select: none;">
<div class="tablesorter-header-inner">
<p>Price</p>
</div>
</th>
</tr>
</thead>
<tbody id="category_content" aria-live="polite" aria-relevant="all">
<tr class="tr__product product-id-001" data-pb-id="001">
<td class="td__name">
<a>
<div class="td__imageWrapper">
<div class="td__image">
<img src="" alt="AMD">
</div>
</div>
<div class="td__nameWrapper">
<p>AMD 5000x</p>
</div>
</a>
</td>
<td class="td__price">
<p>499</p>
<a href="/MAIN.html">
<button class="btn btn--small btn--add" data-product-tag="gd001" >Add</button>
</a>
</td>
</tr>
<tr class="tr__product product-id-002" data-pb-id="002">
<td class="td__name">
<a>
<div class="td__imageWrapper">
<div class="td__image">
<img src="" alt="AMD">
</div>
</div>
<div class="td__nameWrapper">
<p>AMD Ryzen 5</p>
</div>
</a>
</td>
<td class="td__price">
<p>599</p>
<a href="/MAIN.html">
<button class="btn btn--small btn--add" data-product-tag="gd002" >Add</button>
</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
Third HTML page
<html>
<body>
<table class="productList--detailed" id="paginated_table" role="grid">
<thead>
<tr role="row" class="tablesorter-headerRow">
<th class="th--sortable tablesorter-header tablesorter-headerUnSorted th--unsorted" data-column="1" tabindex="0" scope="col" role="columnheader" aria-disabled="false" aria-controls="paginated_table" unselectable="on" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort" style="user-select: none;">
<div class="tablesorter-header-inner">
<p>Product</p>
</div>
</th>
<th class="th--sortable tablesorter-header tablesorter-headerUnSorted th--unsorted" data-column="7" tabindex="0" scope="col" role="columnheader" aria-disabled="false" aria-controls="paginated_table" unselectable="on" aria-sort="none" aria-label="Price: No sort applied, activate to apply an ascending sort" style="user-select: none;">
<div class="tablesorter-header-inner">
<p>Price</p>
</div>
</th>
</tr>
</thead>
<tbody id="category_content" aria-live="polite" aria-relevant="all">
<tr class="tr__product product-id-001" data-pb-id="001">
<td class="td__name">
<a>
<div class="td__imageWrapper">
<div class="td__image">
<img src="" alt="Cooler Master">
</div>
</div>
<div class="td__nameWrapper">
<p>Cooler Master</p>
</div>
</a>
</td>
<td class="td__price">
<p>289</p>
<a href="/MAIN.html">
<button class="btn btn--small btn--add" data-product-tag="gd001" >Add</button>
</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
CSS
.xs-col-12{
width: 100%;
}
th{
color: #191b2a;
padding: 0.5rem 0.5rem 0.5rem 0;
font-size: 0.75rem;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
line-height: 1;
font-weight: normal;
text-align: left;
vertical-align: bottom;
}
tr{
border-color: #616161;
border-top-style: solid;
border-top-width: 1px;
}
table td{
font-size: 0.75rem;
font-weight: 700;
line-height: 1.25;
width: 100px;
padding: 0.5rem 1.5rem 0.5rem 0;
border-color: #e6f0f1;
border-top-style: solid;
border-top-width: 1px;
}
table tbody tr td{
height: 48px;
font-size: 0.75rem;
}
.td__component a{
background-color: transparent;
text-decoration: none;
color: #2c87c3 ;
}
.button__add{
padding: 0.20rem 1.375rem;
font-size: 0.75rem!important;
background-color: #2c87c3;
color: #ffffff;
border-radius: 0.25rem;
text-decoration: none!important;
line-height: 1.25rem;
border-style: solid;
cursor: pointer;
display: inline-block;
text-align: center;
border-width: 2px;
}
.td__name{
padding-top: 0.25rem;
padding-bottom: 0.25rem;
font-size: 0.875rem;
line-height: 1.5;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.td__name a{
color: #191b2a;
display: table;
text-decoration: none;
}
.td__imageWrapper{
line-height: 1.25;
display: table-cell;
vertical-align: middle;
width: 50px important;
height: 50px important;
}
.td__image{
border-color: #dbdbdb;
border-style: solid;
border-width: 1px;
padding: 4px;
vertical-align: middle;
position: relative;
text-align: center;
width: 50px;
height: 50px;
background-color: #fff;
}
.td__image img{
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
.td__nameWrapper{
vertical-align: middle;
padding-left: 1rem;
line-height: 1.25;
display: table-cell;
}
.specLabel{
display: none;
}
.td__tdp{
font-size: 0.75rem;
line-height: 1.5;
font-weight: 400;
color: #26293b;
}
.td__price{
white-space: nowrap;
}
.btn--small {
padding: 0.125rem 0.375rem;
font-size: 0.75rem!important;
margin-left: 0.5rem;
line-height: 1.25rem;
}
.btn {
background-color: #2c87c3;
color: #ffffff;
border-color: #2c87c3;
font-size: 1.125rem;
font-weight: 700;
border-radius: 0.25rem;
text-decoration: none!important;
background-image: none;
border-style: solid;
border-width: 1px;
user-select: none;
cursor: pointer;
display: inline-block;
text-align: center;
border-width: 2px;
transition: background-color 0.1s ease 0s,border-color 0.1s ease 0s;
text-transform: none;
overflow: visible;
font: inherit;
margin: 0;
padding: 0.125rem 0.375rem;
}
my jquery
const add = document.querySelector('.btn--add');
const buttonADD = document.querySelector('.button__add');
const tdimg = document.querySelector('.td__image');
const tdname = document.querySelector('.td__name');
const tdprice = document.querySelector('.td__price');
add.addEventListener('click', function(){
$(buttonADD).hide('');
$(tdimg).show('');
$(tdname).show('');
$(tdprice).show('');
});
I appreciate any help to fix this problem