Jump to content

Javascript not seeming to work

Recommended Posts

I have injected code using html and java script but it is not displaying anything. Any help would be appreciated.

 

<script>const sheetId = '16e1s9-BJDLh-evTsbSnZunE9KkhSlqVdfvLIHhw9BeQ';
const range = 'Sheet1!A1:C10'; // Replace with the range of cells where your data is located
const url = `https://docs.google.com/spreadsheets/d/${sheetId}/values/${range}?key=AIzaSyB0iPz1HM2uQtSIRUN3tr-q70jLEUPsm9o`;

fetch(url)
  .then(function(response) {
    return response.json();
  })
  .then(function(data) {
    // Find the row that matches the web element with the ID of bWIRlk1WzjWYmmolriHL
    const row = data.values.find(function(row) {
      return row[0] === 'bWIRlk1WzjWYmmolriHL';
    });
    if (row) {
      // Update the webpage with the data from the matching row
      const webElement = document.getElementById('bWIRlk1WzjWYmmolriHL');
      webElement.textContent = row[1];
    }
  })
  .catch(function(error) {
    console.error(error);
  });
</script>

Link to comment
  • Replies 1
  • Views 209
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.