Jump to content

Injected HTML Code shows up but doesn't run!

Recommended Posts

Hi! I'm trying to add a BMI Calculator on my website but the code doesn't run (I found it online). You do see the image of the BMI tool, but it doesn't make any calculations. I've also contacted customer support and they can't help :/. See pictures and code below. FYI the BMI formula is as following: BMI = kg/m2.

I would be very grateful with any help!

Esther 

-----

Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="calculator-container">
        <h1>BMI CALCULATOR</h1>
        <p>Height in meters:</p>
        <input class="height-input-field" type="text">
        <p>weight in kilograms:</p>
        <input class="weight-input-field" type="text"><br>
        <button class="calculate"> Calculate</button>
    </div>
    <h3 class="result"></h3>
    <p class="result-statement"></p>
    <script src="script.js"></script>
</body>
</html>

Screenshot 2022-12-12 at 11.18.15.png

Link to comment
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

2 hours ago, EstherH said:

Hi! I'm trying to add a BMI Calculator on my website but the code doesn't run (I found it online). You do see the image of the BMI tool, but it doesn't make any calculations. I've also contacted customer support and they can't help :/. See pictures and code below. FYI the BMI formula is as following: BMI = kg/m2.

I would be very grateful with any help!

Esther 

-----

Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="calculator-container">
        <h1>BMI CALCULATOR</h1>
        <p>Height in meters:</p>
        <input class="height-input-field" type="text">
        <p>weight in kilograms:</p>
        <input class="weight-input-field" type="text"><br>
        <button class="calculate"> Calculate</button>
    </div>
    <h3 class="result"></h3>
    <p class="result-statement"></p>
    <script src="script.js"></script>
</body>
</html>

Screenshot 2022-12-12 at 11.18.15.png

1. Have you checked the link for js code?

image.png.1107b93b22bd7d1c645b55bfad7a06bf.png

You should try uploading the script file on squarespace and use the following link on src value:

<script src="/s/script.js"></script>

Or add the js directly on <script> tag

 

2. I think you should only add the HTML 

<div class="calculator-container">
  <h1>BMI CALCULATOR</h1>
  <p>Height in meters:</p>
  <input class="height-input-field" type="text">
  <p>weight in kilograms:</p>
  <input class="weight-input-field" type="text"><br>
  <button class="calculate"> Calculate</button>
</div>
<h3 class="result"></h3>
<p class="result-statement"></p>

not include the html tag or body tag because Squarespace has already them, so it may cause some confilct

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date format)
💫 Animated Buttons (Referral URL)
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

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.