I have a condition that when the input value is greater than 100, another bottle is added, but I don't know where to insert another functions so that the anothers bottles displays the water level I need, i want set this for eight bottles. I was trying to add a new function to a function addBottle ans others function, but only got errors
let inputWaterLevel = document.querySelector('[name=water-level]');
let heightLiquid = +tubeLiquid.getAttribute('height');
let yLiquid = +tubeLiquid.getAttribute('y');
let liquidPercent = heightLiquid/100;
inputWaterLevel.addEventListener('input', updateWaterLevel);
function updateWaterLevel() {
let value = +this.value;
let height = liquidPercent * value;
let y = yLiquid + (heightLiquid-height);
tubeLiquid.setAttribute('height', liquidPercent * value )
tubeLiquid.setAttribute('y', y )
}
let addBottle2 = () => {
inputWaterLevel.id = 'inpId';
let inpId = document.getElementById('inpId')
inpId.addEventListener("input", () => {
if (inpId.value > 100) {
document.getElementById("bot2").style.display = 'block';
}
else if (inpId.value <= 100){
document.getElementById("bot2").style.display = 'none';
}
});
}
addBottle2()
.cont{
display: flex;
}
#bot2{
display: none;
}
<p><input type="number" min="0" max="200" value="100" name="water-level" /></p>
<div class="cont">
<div class="bot1">
<svg viewBox="0 0 300 300" width="150">
<clipPath id="clip">
<rect x="118" y="68" width="64" height="228" rx="20" ry="20" />
</clipPath>
<image width="300" xlink:href="https://i.ibb.co/HGFQYTj/bottle.png" />
<rect clip-path="url(#clip)" id="tubeLiquid" x="115" y="58" width="70" height="233" fill="#74ccf4" />
</svg>
</div>
<div id="bot2">
<svg viewBox="0 0 300 300" width="150">
<clipPath id="clip2">
<rect x="118" y="68" width="64" height="228" rx="20" ry="20" />
</clipPath>
<image width="300" xlink:href="https://i.ibb.co/HGFQYTj/bottle.png" />
<rect clip-path="url(#clip2)" id="tubeLiquid2" x="115" y="58" width="70" height="233" fill="#74ccf4" />
</svg>
</div>
</div>