Hi there! So these are my errors;
Can someone help me out? Please let me know if you need more screenshots or if you have any idea of what’s going on! Please and thnk you
Hello, we would likely need to know more about the code. It seems that calcul_imc_final.html
line 97
has an issue where you are trying to access value
from a variable but the variable is null
. This is a very common example of how this may occur:
<body>
<input class="myInput" value="asdf">
<script>
// I misspelled myInput and instead typed myInputs
// so this will return null rather than the element reference
const input = document.body.querySelector('.myInputs');
console.log(input.value); // Uncaught TypeError: Cannot read property 'value' of null
</script>
</body>
Thank you so much for answering! I don’t seem to quite understand… This is my script:
And I can’t seem to figure out what am I doing wrong with the animation, I really appreciate the help! Thanks again
my guess is that your issue is in line 99:
var barra = document.getElementById("barra").value;
where there is not an element that has id="barra"
on your page. Please make sure nothing is mispelled and that there is an element with the id
barra
.
Alternatively it can also be in lines 72 and 73 - you will have to check those IDs as well
This should be enough? I’m so sorry, I’m very new at javascript, I appreciate your patience
This is fine. You can see that pes
and alcada
both are <input>
elements which have .value
in them. See documentation for value
here
unfortunately <div id="barra">
is an HTMLDivElement
which does not have a .value
on it. I think what you want is the reference to the div itself in which you can simply just do:
var barra = document.getelementById("barra");
from there, you should be able to set style on it.
Also, you should be able to copy and paste your code into this forum and you can format it with the “code” / “preformatted text” button:
Thank you so mcuh! I’ll try it out and let you know, thanks!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.