Transforming dynamic table text into an image: Step-by-step guide

I have a live scoreboard on my website that pulls information from another site, making the content dynamic. I want to enhance the display by replacing certain elements in the table with images, such as displaying logos instead of club names. However, my knowledge of CSS and jQuery is limited, so I'm seeking assistance with implementing these changes using HTML.

Below is the code that generates the table:

<style>
  table,
  td,
  th {
    border: 1px solid #ddd;
    text-align: center;
    font-size: 15px;
  }
  
  table {
    border-collapse: collapse;
    width: 100%;
  }
  
  th,
  td {
    padding: 1px;
  }
  
  th {
    background-color: #c71b1b
  }
  
  th,
  td1 {
    padding: 1px;
  }
  
  th {
    background-color: #c71b1b
  }
</style>


<div style="overflow-x:auto;">
  <table cellspacing="20">
    <tbody>
      <tr>
        <th colspan="5">
          <h1>MEN</h1>
        </th>
      </tr>
      <tr>
        <td width=14%>DATE</td>
        <td width=13%>TIME</td>
        <td width=12%>HOME</td>
        <td width=12%>AWAY</td>
        <td width=49%>SCORE</td>
      </tr>
    </tbody>
  </table>
  <table cellspacing="20">
    <tbody>
      <tr>
        <div class="pb-dynamic" id="block-main-men">
          <p><img src="//www.pointbench.com/pointbench/img/pb-loading-1.gif" /></p>
        </div>
      </tr>
    </tbody>
  </table>
  <table cellspacing="20">
    <tbody>
      <tr>
        <th colspan="5">
          <h1>WOMEN</h1>
        </th>
      </tr>
      <tr>
        <td width=14%>DATE</td>
        <td width=13%>TIME</td>
        <td width=12%>HOME</td>
        <td width=12%>AWAY</td>
        <td width=49%>SCORE</td>
      </tr>
    </tbody>
  </table>
  <table cellspacing="20">
    <tbody>
      <tr>
        <div class="pb-dynamic" id="block-main-women">
          <p><img src="//www.pointbench.com/pointbench/img/pb-loading-1.gif" /></p>
        </div>
      </tr>
    </tbody>
  </table>
</div>

<!-- Include JS script to do the job, block definition(s) and main function call -->
<script src="//stats.pointbench.com/pointbench/js/pb-update-ex.js" type="text/javascript"></script>
<script type="text/javascript">
  <!--//--><![CDATA[// ><!--


  blockdefs = [{
      leagueid: 'bel/29/2022',
      blocktype: 'team-games',
      target: 'block-main-men',
      teamid: '413'
    },
    {
      leagueid: 'bel/30/2022',
      blocktype: 'team-games',
      target: 'block-main-women',
      teamid: '207'
    }
  ];

  PBShowBlocks(blockdefs);


  //--><!]]>
</script>
<!-- End -->
</div>

</div>

Answer №1

The type of table layout you are using does not align with the expected structure. It is possible that the browser is adjusting the tags to fit the correct hierarchy, causing issues with the selector logic in the image replacement function.

Consider the following structure:

<table cellspacing="20">
   <tbody>
      <tr>
         <td>       
            <div class="pb-dynamic" id="block-main-women">
               <p><img src="//www.pointbench.com/pointbench/img/pb-loading-1.gif" /></p>
            </div>
         </td>
      </tr>
   </tbody>
</table>

Answer №2

UPDATE: After reviewing the code, I have identified the necessary corrections. Please refer to the modified code below.


  1. The issue lies in the incorrect usage of the src tags. In the script and image tags, you used something like "//google.com" which is not a valid URL format. Typically, when fetching from another URL, you should use

    src="https://google.com/"

  2. Upon inspecting the linked JS file, an error was found. This can be observed in the console log. The file is referencing the css file pb-blocks.css at

    stats.pointbench.com/css/pb-blocks.css
    . The correct path should be
    stats.pointbench.com/pointbench/css/pb-blocks.css
    as indicated here:

    If you have access to the server, you can rectify this issue there. Alternatively, a fix will be provided at the end of this response.


To resolve the broken JS file, access the file's URL, copy its content, and place it in your public/assets route.

Search for every occurrence of

document.getElementsByTagName("head")[0].appendChild(fileref);
. Above this line, you will find
fileref.setAttribute("href", gUpdateDomain + "pointbench/css/pb-blocks.css");
. Replace it with
fileref.setAttribute("href", "https://stats.pointbench.com/pointbench/css/pb-blocks.css");
. This modification should be done twice.

Additionally, your table structure is incorrect. Below is the corrected table structure:

    <table cellspacing="20">
        <thead>
            <tr>
              <th></th>
            </tr>
        </thead>
        <tbody>
            <tr>
              <td></td>
            </tr>
        </tbody>
    </table>
    

Overall, your code needs some refinement for better readability. Unnecessary elements and closing tags without corresponding opening tags have been removed. Refer to the updated code below:

... (Your updated code will be presented here) ...


In regards to your inquiry, the replacement of team initials with team logos is achievable. Preparation of team logos is required, either by storing them locally or fetching them through an API. Assuming there's a limited number of team logos, downloading and storing them locally is feasible, enabling the substitution of initials with logos.

For demonstration purposes, a sample logo URL from the internet will be used.

Assuming the team name cells are the 2nd and 3rd cells in each row of your table, the following code snippet can be applied:

... (Your logo implementation code will be presented here) ...

Before https://i.sstatic.net/BJSq1.png

After https://i.sstatic.net/svgk1.png

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

Efficiently submitting a directory with jQuery's AJAX capabilities

I am attempting to send an ajax request in the following manner: $.ajax({ url: 'directory/file.php', type: 'POST', data: 'param1=' + param1 + '&param2=' + param2, ...

How can I attach an existing event to a dynamically loaded element using AJAX?

In the main page of my website, there is a button: <button class="test">test</button> Additionally, I have included the following script in my code: $('.test').on('click',function(){ alert("YOU CLICKED ME"); } ...

Having trouble getting Jquery to work with an Ajax call in the cart drawer. Any suggestions on how to resolve this issue

I used this code to implement a collapsible feature in my Cart Drawer, but it seems to stop functioning after an Ajax call. Any suggestions on how to troubleshoot and fix this issue? Just for context, I included onclick="return false;" in the bu ...

Utilizing a raycasting technique in conjunction with the camera to achieve a dynamic crosshair effect reminiscent of Google Cardboard

I'm looking for a way to implement the Google Cardboard crosshair effect in my three.js scene. Essentially, I want to create a dot or crosshair in the center of the screen for VR navigation. How can I achieve this and use a raycaster to interact with ...

Selecting radio button does not update corresponding label

I am having an issue with setting a radio button as checked. In the example snippet, it works perfectly fine but on my localhost, it is not working. Even though the input gets checked, the label does not change. Surprisingly, if I set another radio button ...

Creating a unique seal, badge, or widget in Django is a fun and rewarding project

Here are some examples of what I want to accomplish: View the gif showcasing the function Visit https://sectigo.com/trust-seal Check out another gif demonstrating the function Explore https://www.carandtruckremotes.com/ Don't miss this gif showin ...

Obtaining the Tinymce Editor Instance using WordPress JavaScript

I am currently in the process of developing a Wordpress plugin that adds a customized metabox below the post editor, including a button. Additionally, the plugin loads a Javascript file just before the closing </body> tag. OBJECTIVE My main goal wi ...

Transitioning from mui version 4 to version 5 leads to an error message: "TypeError: Cannot access 'keyboardDate' properties of undefined"

After updating from MUI v4 to version v5, I encountered failing tests with the following error: TypeError: Cannot read properties of undefined (reading 'keyboardDate') 17 | it("should render correctly without any errors", () =& ...

How can I implement user-specific changes using Flask?

I am a beginner with Flask and I am working on a project where users can sign up, and if the admin clicks a button next to their name, the user's homepage will change. Below is the Flask code snippet: from flask import Flask, redirect, url_for, render ...

Verify JSON data from server using AngularJS

My understanding is that in Angular, the HTTP service has two checks for 'success' and 'error' when connecting to a service. I have already handled these checks as my first step. The issue I am facing now is with the data in my JSON fi ...

Transmit information to Vue.js component

I am encountering an issue while attempting to transfer data from one component to another. Can someone provide assistance? Below is the code snippet: <template> <div class="q-pa-md" style="max-width: 900px"> <div v-if="fields.length" ...

Using jQuery.post to select and manipulate the target div displaying Google search results

I am trying to implement a custom form and display the results in a specific target DIV ('results') using ajax. However, I am facing difficulties and unable to figure out what is going wrong. Even after referring to this demo (https://api.jquery ...

Troubleshooting Hierarchical Ordering in Django-MPTT's recursetree Function

I am currently utilizing the django-mptt package within my Django application, and I have encountered an issue when trying to use the .order_by() method in conjunction with a filter. Despite attempting different criteria for ordering, the results remain un ...

What is the best way to implement a toggle function using jQuery in PHP/WordPress without having to refresh the entire page?

I was looking to implement a toggle effect using JQuery for the hyperlink text (which will be replaced by a button), but unfortunately, it ended up refreshing the entire page when I tried doing it in PHP/WordPress. Thank you for your feedback! jQuery(doc ...

Seamless blend of images with a stunning mosaic transition effect

I attempted to create a mosaic effect on my carousel similar to this example: , but not exactly like this. I want to include control buttons for next and previous, and have images in HTML tag. However, my attempt is not working and I need help. This is ...

How can one effectively develop a component library that is compatible with both React and Preact?

I'm currently in the midst of a project that involves both React and Preact. I've come across a situation where I need to utilize the same component for both React and Preact. Would it be wise to package the component into an npm library? What a ...

Detecting media queries for the Samsung Galaxy S3 and S4 devices

I have been working on implementing media queries to show text boxes with different styles for iPhone 5, iPhone 6, Samsung Galaxy SIII, and Samsung Galaxy S4. Initially, everything was working fine for iPhone 5 and iPhone 6, but when I switched from an i ...

Tips for refreshing the 'state' of an Angular Router component

I'm facing an issue with passing data between pages using Angular routing. Everything works as expected when navigating to the "next" page for the first time. However, upon returning to the home page and selecting a different item, the Router's s ...

Tips for incorporating a value within the AngularJS select function

Having an issue with passing a list value in the html select method using AngularJS. Here is my code: app.js $scope.subcategory = function() { var query = "SELECT unit FROM Length;"; $cordovaSQLite.execute(db, query).then(function(res) { ...

Guide to moving a 3D model and initiating animation in threejs when a key is pressed

In the midst of a project where a person (gltf object) walks based on key presses, I have successfully updated the object position accordingly. However, I'm encountering difficulty in rotating the object when the left/right keys are pressed and ensur ...