0

I have the below table which is created through JavaScript - by creating elements, text nodes:

<table>
  <tr>
    <th>A</th>
    <th>B</th>
  </tr>
  <tr>
    <td>D</td>
    <td><img src="" /></td>
  </tr>
</table>

The JavaScript code to create the relevant row(s) with the images, but this just displays the images in sequence:

// obj.images is an array of base64 image strings 
for (const imgString of obj.images) {
  const rows = document.createElement("td");
  const base64 = `data:image/jpeg;base64,${imgString}`;

  const imgElement = document.createElement("img");
  imgElement.src = base64;
  imgElement.width = "300";

  rows.appendChild(imgElement); // rows is a <td> HTML element 
  row.appendChild(rows); // row is a <tr> HTML element, defined outside loop
}

The table will always have 2 headers, A and B, and the rows will have a letter (example: D) and image(s). Problem is, there can be multiple images so in column B, I want to display all the images (which are saved as arrays of base64 strings) in a paginated way where I can scroll left or right to display all images if there are multiple. How can I approach this, preferably with CSS and JavaScript only if possible? The images in column B should ideally be resized to be the same.

  • I would suggest you actually TRY something here by putting your pagination attempt code in place in the question so we can help you fix it after you study https://developer.mozilla.org/en-US/docs/Learn/HTML/Tables/Advanced#adding_structure_with_thead_tfoot_and_tbody – Mark Schultheiss May 09 '23 at 12:16
  • As it currently stands this is a duplicate: https://stackoverflow.com/q/19605078/125981 – Mark Schultheiss May 09 '23 at 12:17

0 Answers0