如何解决地址簿/数组,无法上班/Jaca Script
我无法让这个程序运行,还试图添加搜索按钮,如果有人可以检查问题是什么。`
尝试制作一个程序,我可以在其中添加名称/kohde、osoite/adress、hinta/price、ala/space。 制作了一个数组 asunnot 我尝试从盒子推到数组,然后制作搜索按钮来搜索名称,最后一个按钮来计算空间/价格。
<form>
<div class="Laatikko"></div>
<label for="kohde">Kohde</label>
<br>
<input type="text" id="kohde" placeholder="Kohde">
</div>
<div class="Laatikko"></div>
<label for="osoite">Osoite</label>
<br>
<input type="text" id="osoite" placeholder="Osoite">
</div>
<div class="Laatikko"></div>
<label for="hinta">Hinta</label>
<br>
<input type="number" id="hinta" placeholder="Hinta">
</div>
<div class="Laatikko"></div>
<label for="ala">Pinta-ala</label>
<br>
<input type="number" id="ala" placeholder="Ala">
<div>
<div class="Laatikko">
<button id="nappi">Lisää asunto/kohde</button>
</div>
<div class="Laatikko">
<button id="nappi">Etsi asunto</button> //search asunto
<button id="nappi">Laske pinta-ala</button> //count pinta-ala + hinta
</div>
<div id="msg">
<pre></pre>
</div>
</div>
</div>
<script>
let asunnot = []; //array asunnot
const lisaaAsunto = (ev)=> { //add asunto
ev.preventDefault();
let asunto = {
kohde: document.getElementById("kohde").value,osoite: document.getElementById("osoite").value,hinta: document.getElementById("hinta").value,ala: document.getElementById("ala").value
}
asunnot.push(asunto);
document.forms[0].reset();
document.getElementByID("nappi").addEventListener("lisaa",lisaaAsunto);
console.warn("lisatty",{asunnot} );
let pre = document.querySelector("#msg pre");
pre.textContent = "\n" + JSON.stringify(asunnot,"\t",2);
}
</script>
</form>
`
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。