За последние 24 часа нас посетили 21889 программистов и 1010 роботов. Сейчас ищет 731 программист ...

Не работает функция поиска массива и конструктор

Тема в разделе "JavaScript и AJAX", создана пользователем Chivas, 31 май 2021.

Метки:
  1. Chivas

    Chivas Новичок

    С нами с:
    28 май 2021
    Сообщения:
    1
    Симпатии:
    0
    Код (Text):
    1.  
    2. <!DOCTYPE html>
    3. <html>
    4. <head>
    5. <title></title>
    6. <meta charset="utf-8"/>
    7. </head>
    8. <body class="bo1">
    9. <!--Тут вводные "жилище, порядковыйномер, адрес, цена, количество кв метров "-->
    10. Asunto: <input id= "asunto"/>
    11. </br>
    12. kohdenumero: <input id= "kohdeNumero"/>
    13. <br/>
    14. osoite:<input id="osoite"/>
    15. </br>
    16. hinta:<input id= "hinta"/>
    17. </br>
    18. pinta-ala:<input id="pintaAla"/>
    19. </br>
    20. <div id= "tulostusAlue"></div>
    21. </br>
    22. nelio hinta:<input id ="nelioHinta"/>
    23. </br>
    24. <button onclick="lisaa();">Lisää asunto</button>
    25. <button onclick="tulostaKaikki();">Tulosta kaikki</button>
    26. <button onclick="haeAsunto();">Hae asunto</button>
    27. <!--посчитать цену за кв метр-->
    28. <button onclick="laskeNelioHinta();">Laske nelio hinta</button>
    29. <script>
    30. // добавить
    31. let asunnot = [];
    32. function lisaa (){
    33. let asunto = document.getElementById ("asunto").value;
    34. let kohdeNumero = document.getElementById ("kohdeNumero").value;
    35. let osoite = document.getElementById ("osoite").value;
    36. let hinta = document.getElementById ("hinta").value;
    37. let pintaAla = document.getElementById ("pintaAla").value;
    38. asunnot.push(asunto, kohdeNumero, osoite,hinta,pintaAla);
    39. }
    40. // вывести на экран . Должно выводить всю инфу о жилище
    41. function tulostaKaikki(){
    42. let tulostus = "";
    43. for (let i = 0; i < asunnot.length; i++){
    44. tulostus += "<br/>" + asunnot [i]
    45. }
    46. document.getElementById ("tulostusAlue").innerHTML = tulostus;
    47. }
    48. // найти
    49. function haeAsunto(){
    50. let tulostus = asunnot [i];
    51. for(let i =0;i <asunnot .length;i++){
    52. if(asunto == asunto[i])
    53. document.getElementById("tulostusAlue").innerHTML = asunnot;
    54.  
    55. }
    56. }
    57. // посчитать цену кв м constructor ??
    58. function laskeNelioHinta (){
    59. this.hinta = hinta;
    60. this.pintaAla = pintaAla;
    61. return this. hinta / this. pintaAla;
    62. }
    63. </script>
    64. </body>
    65. <link rel="stylesheet" href="talo1.css">
    66.  
    67. </html>
     

    Вложения:

    • talo.zip
      Размер файла:
      998 байт
      Просмотров:
      0
    #1 Chivas, 31 май 2021
    Последнее редактирование модератором: 1 июн 2021
  2. MouseZver

    MouseZver Суперстар

    С нами с:
    1 апр 2013
    Сообщения:
    7.748
    Симпатии:
    1.321
    Адрес:
    Лень
    Называется - убей в себе Недопрограммиста. Чего надо, зачем пришел...