Sada je: 28 ožu 2024, 08:57.
C, C++, Java, PHP, Ruby...

Moderator/ica: Moderatori/ce

Pravila foruma
U naslovu teme unutar uglatih zagrada navesti o kojem jeziku je riječ. Primjer: [Java]
Nisam mogao napisati cijeli problem u naslov pa evo detaljan opis.

Ovo je dio mog koda

Kod: Označi sve
function tlak_smr () {
    tlak_nula ()
    var TTx = document.getElementById("tt").value;
    var P0xx = tlak_nula ()
    if (P0xx < 700) {
        P0x = P0xx + 10000
    } else {
        P0x = P0xx
    }
    var TS = TTx / 10;
    var T_SMR = TS + (0.5 * hb / 100);
    var T_S = (TS + T_SMR) / 2;
    var hg = hb * 9.81;
    var RT = 286.9 * (T_S + 273.15);
    var hgRT = hg / RT;
    var k = Math.pow(e, hgRT) - 1;
    var dP = P0x * k;
    var P_hPa = P0x + dP;
    var P_hPaf = parseFloat(P_hPa).toFixed(1);
    if (P_hPa < 1000) {
          PPPP = (P_hPa * 10).toFixed(0);
     } else {
        PP = ((P_hPa - 1000) * 10).toFixed(0);
        PPPP = String('0000' + PP).slice(-4);
       }
    document.getElementById("PPPP").innerHTML = PPPP;
    return PPPP;
}


Prije ove funkcije imam nekoliko funkcija i uredno rade. Međutim kod ove, dio var TTx = document.getElementById("tt").value; uvijek izađe da TTx nije definiran te u cijeloj funkciji TTx vodi kao 0. Dio u HTML-u gdje se unosi taj iznos je kodiran ovako

Kod: Označi sve
<input class="unos" type="text" size="3" id="tt">


JS se nalazi u istoj datoteci kao i HTML. Prije ovoga sam probao da JS bude u posebnoj datoteci, ali tada se problem prvi put pojavio pa sam ih odlučio držati u istoj datoteci. Međutm, problem je ostao. Do sada svi drugi getElementById rade bez problema.

Već jedan cijeli dan tražim u čemu je problem, ali ga ne uspjevam naći. Molio bih da oni koji se razumiju u JS daju prijedlog što da napravim da mi JS kod preuzme vrijednost iz HTML-a
Linux za srce i dušu.

GitHub
Twitch
YouTube
Avatar
Postovi: 42
Postovi: 42
Pridružen/a: 09 ožu 2020, 19:12
Lokacija: Zagreb
Podijelio/la zahvalu: 2 puta
Primio/la zahvalu: 1 puta
Spol: M
Ajme kakva imena varijabli :sokiran

Probaj izvrtit ovo u konzoli:

document.querySelectorAll("#tt")

Ako je to jednoclan niz (a trebao bi biti, jer je to ID), onda bi ti ovo trebalo sigurno raditi:

document.querySelector("#tt").value

Ako to nije jednoclan niz, onda definitivno trebaš promijeniti IDjeve :)

Inače, ne vidim ništa krivo u ovim snippetima koje si tu pasteao.
Avatar
Site Admin
Postovi: 4639
Site Admin
Postovi: 4639
Pridružen/a: 07 ožu 2009, 17:00
Podijelio/la zahvalu: 101 puta
Primio/la zahvalu: 209 puta
Spol: M
OS: fedora 34
iweb je napisao/la:Ajme kakva imena varijabli :sokiran

Probaj izvrtit ovo u konzoli:

document.querySelectorAll("#tt")

Ako je to jednoclan niz (a trebao bi biti, jer je to ID), onda bi ti ovo trebalo sigurno raditi:

document.querySelector("#tt").value

Ako to nije jednoclan niz, onda definitivno trebaš promijeniti IDjeve :)

Inače, ne vidim ništa krivo u ovim snippetima koje si tu pasteao.


document.querySelector("#tt").value u konzoli daje vrijednost, ali kad je u kodu onda isto ostavlja nedefiniranu varijablu.
Linux za srce i dušu.

GitHub
Twitch
YouTube
Avatar
Postovi: 42
Postovi: 42
Pridružen/a: 09 ožu 2020, 19:12
Lokacija: Zagreb
Podijelio/la zahvalu: 2 puta
Primio/la zahvalu: 1 puta
Spol: M
E pa moguće je da ti ga ne shvaća kao broj: onda nije undefined već NaN. Probaj zamotati querySelector u parseInt()
Avatar
Site Admin
Postovi: 4639
Site Admin
Postovi: 4639
Pridružen/a: 07 ožu 2009, 17:00
Podijelio/la zahvalu: 101 puta
Primio/la zahvalu: 209 puta
Spol: M
OS: fedora 34
iweb je napisao/la:E pa moguće je da ti ga ne shvaća kao broj: onda nije undefined već NaN. Probaj zamotati querySelector u parseInt()


Nope... Ne pomaže. Kada u Chromeu odem na konzolu i upišem console.log(TSx) (TSx je varijabla koja bi trebala imati unesenu vrijednost), dobijem sljedeću poruku: "Uncaught ReferenceError: TSx is not defined at <anonymous>:1:13"

P.S. Da li bi u pronalaženju problema pomoglo da stavim cijeli kod?
Linux za srce i dušu.

GitHub
Twitch
YouTube
Avatar
Postovi: 42
Postovi: 42
Pridružen/a: 09 ožu 2020, 19:12
Lokacija: Zagreb
Podijelio/la zahvalu: 2 puta
Primio/la zahvalu: 1 puta
Spol: M
Sven je napisao/la:
iweb je napisao/la:E pa moguće je da ti ga ne shvaća kao broj: onda nije undefined već NaN. Probaj zamotati querySelector u parseInt()


Nope... Ne pomaže. Kada u Chromeu odem na konzolu i upišem console.log(TSx) (TSx je varijabla koja bi trebala imati unesenu vrijednost), dobijem sljedeću poruku: "Uncaught ReferenceError: TSx is not defined at <anonymous>:1:13"

P.S. Da li bi u pronalaženju problema pomoglo da stavim cijeli kod?


Pa jasno da ju nećeš dobiti sa console.log kad je ta varijabla unutar fje tlak_smr - samo tamo živi, nije globalna.

Eventualno bi pomogao cijeli kod, ali ne znam ovako reći o čemu je riječ :hmm
Avatar
Site Admin
Postovi: 4639
Site Admin
Postovi: 4639
Pridružen/a: 07 ožu 2009, 17:00
Podijelio/la zahvalu: 101 puta
Primio/la zahvalu: 209 puta
Spol: M
OS: fedora 34
Evo... Cijeli kod.

Kod: Označi sve
<html>
  <head>
    <meta charset="UTF-8" />
    <title>SYNOP kalkulator V.3</title>
    <style>
      table, th, td {
        border: 1px solid black;
        border-collapse: collapse;
       
      }
      td {
        min-width: 70px;
       
      }
      .centar {
       text-align: center;
      }
      .unos {
        background-color: turquoise;
      }
      .unos1 {
        background-color: blue;
        color: white;
      }
      .izracun {
        background-color: gray;
      }
      .prazno {
        background-color: black;
      }
      .vrh {
        background-color: yellow;
        text-align: center;
      }
    </style>
  </head>
  <body  onload="osnovno ()">
    <script>
      //varijable koje se prilagođavaju postaji
var iii = 246; //broj postaje
var h = 167; //nadmorska visina postaje [m]
var hb = 167.93; //nadmorska visina barometra [m]
var hsr = 290; //srednja nadmorska visina u krugu radiusa 150 km od postaje [m]
var GS = 46.3; //geografska širina postaje [0.1°]
var pk = 100; //postotak kopna u krugu radiusa 150 km
var db = 0; //dubina mora ispod postaje [m]
var dbs = 0; //srednja dubina mora ispod postaje u krugu od 150 km [m]
var ip = 0; //izobarna ploha (0 [SMR], 8 [850 hPa], 9 [925 hPa])
var bi1 = 1; //mjerne jedinice na barometru (1 [mmHg] ili 2 [hPa])
var bi2 = 2; //koriekcija po vrsti barometra (1, 2, 3, 4 ili 50)
var tmox = 2; //izvještavanje temperature mora (1 [da], 2 [ne])
var iW = 1; //jedinica brzine vjetra (0 - ocjenjeno [m/s], 1 - mjereno [m/s], 3 - ocjenjeno [kt], 4 mjereno [kt]

//početak tablice

function osnovno () {

    var d = new Date();
    var day = d.getUTCDate();
    var day_sev = String('00' + d.getUTCDate()).slice(-2);
    var month = d.getUTCMonth();
    var year = d.getUTCFullYear();
    var hour = String('00' + d.getHours()).slice(-2);
    if (d.getUTCMinutes() > 49) {
    hour_utc = d.getUTCHours() + 1;
    } else {
    hour_utc = d.getUTCHours();
    }
    if (hour_utc == "24") {
    day_utc = day + 1
    day_utc_i = String ('00' + day_utc).slice(-2);
    hour_utc_i = "00";
    } else {
    hour_utc_i = String('00' + hour_utc).slice(-2);
    day_utc = day_sev;
    }
    hour_sev = d.getUTCHours() + 1;
    hour_sev_i = String('00' + hour_sev).slice(-2);
    var mins = String('00' + d.getUTCMinutes()).slice(-2);
    var vrijeme = "DATUM: " + day + "." + month + "." + year + ". | VRIJEME: " + hour + ":" + mins + " | TERMIN IZVJEŠTAVANJA: " + hour_utc_i + " UTC";
   
    var pos = "POSTAJA: 14" + iii + " | NADMORSKA VISINA: " + h + " m | " + vrijeme;
    if (bi1 == 1) {
    unt = "mmHg"
    } else {
    unt = "hPa"
    }
    if (hour_utc_i == "06") {
      Re = " (12 sati)"
    } else if (hour_utc_i == "18") {
      Re = " (12 sati)"
    } else if (hour_utc_i == "00") {
      Re = " (6 sati)"
    } else if (hour_utc_i == "12") {
      Re = " (6 sati)"
    } else {
      Re = " (Ne izvještava se)"
      document.getElementById('oborina').setAttribute("style", "display:none");
    }
    if (hour_utc_i !== "18") {
      document.getElementById('max').setAttribute("style", "display:none");
    } else {
      document.getElementById('max').setAttribute("style", "display:block");
    }
    if (hour_utc_i !== "06") {
      document.getElementById('min').setAttribute("style", "display:none");
    } else {
      document.getElementById('min').setAttribute("style", "display:block");
    }
    if (hour_utc_i !== "06") {
      document.getElementById('min5').setAttribute("style", "display:none");
    } else {
      document.getElementById('min5').setAttribute("style", "display:block");
    }
    if (hour_utc_i == "06") {
      document.getElementById('sss').setAttribute("style", "display:block");
    } else if (hour_utc_i == "18") {
      document.getElementById('sss').setAttribute("style", "display:block");
    } else {
      document.getElementById('sss').setAttribute("style", "display:none");
    }
    if (hour_utc_i !== "06") {
      document.getElementById('min5').setAttribute("style", "display:none");
    } else {
      document.getElementById('min5').setAttribute("style", "display:block");
    }
    if (hour_utc_i == "12") {
      document.getElementById('r24').setAttribute("style", "display:block");
    } else if (hour_utc_i == "18") {
      document.getElementById('r24').setAttribute("style", "display:block");
    } else {
      document.getElementById('r24').setAttribute("style", "display:none");
    }
    if (ip == "0") {
      bxxx = "P"
    } else {
      bxxx = "H"
    }
    var odjeljak0 =  "AAXX" + " " + day_utc + hour_utc_i + iW + " " + "14" + iii
    document.getElementById("postaja").innerHTML = pos;
    document.getElementById("Re").innerHTML = Re;
    document.getElementById("odjeljak0").innerHTML = odjeljak0;
    document.getElementById("bxxx").innerHTML = bxxx
    document.getElementById('div2').setAttribute("style", "color:red");
    }

function vidljivost () {
    var VVX = document.getElementById("km").value; //vidljivost
    if (VVX < 0.1) {
        VV = 00;
    } else if (VVX == 0.1) {
        VV = 01;
    } else if (VVX == 0.2) {
        VV = 02;
    } else if (VVX == 0.3) {
        VV = 03;
    } else if (VVX == 0.4) {
        VV = 04;
    } else if (VVX == 0.5) {
        VV = 05;
    } else if (VVX == 0.6) {
        VV = 06;
    } else if (VVX == 0.7) {
        VV = 07;
    } else if (VVX == 0.8) {
        VV = 08;
    } else if (VVX == 0.9) {
        VV = 09;
    } else if (VVX == 1) {
        VV = 10;
    } else if (VVX == 1.1) {
        VV = 11;
    } else if (VVX == 1.2) {
        VV = 12;
    } else if (VVX == 1.3) {
        VV = 13;
    } else if (VVX == 1.4) {
        VV = 14;
    } else if (VVX == 1.5) {
        VV = 15;
    } else if (VVX == 1.6) {
        VV = 16;
    } else if (VVX == 1.7) {
        VV = 17;
    } else if (VVX == 1.8) {
        VV = 18;
    } else if (VVX == 1.9) {
        VV = 19;
    } else if (VVX == 2) {
        VV = 20;
    } else if (VVX == 2.1) {
        VV = 21;
    } else if (VVX == 2.2) {
        VV = 22;
    } else if (VVX == 2.3) {
        VV = 23;
    } else if (VVX == 2.4) {
        VV = 24;
    } else if (VVX == 2.5) {
        VV = 25;
    } else if (VVX == 2.6) {
        VV = 26;
    } else if (VVX == 2.7) {
        VV = 27;
    } else if (VVX == 2.8) {
        VV = 28;
    } else if (VVX == 2.9) {
        VV = 29;
    } else if (VVX == 3) {
        VV = 30;
    } else if (VVX == 3.1) {
        VV = 31;
    } else if (VVX == 3.2) {
        VV = 32;
    } else if (VVX == 3.3) {
        VV = 33;
    } else if (VVX == 3.4) {
        VV = 34;
    } else if (VVX == 3.5) {
        VV = 35;
    } else if (VVX == 3.6) {
        VV = 36;
    } else if (VVX == 3.7) {
        VV = 37;
    } else if (VVX == 3.8) {
        VV = 38;
    } else if (VVX == 3.9) {
        VV = 39;
    } else if (VVX == 4) {
        VV = 40;
    } else if (VVX == 4.1) {
        VV = 41;
    } else if (VVX == 4.2) {
        VV = 42;
    } else if (VVX == 4.3) {
        VV = 43;
    } else if (VVX == 4.4) {
        VV = 44;
    } else if (VVX == 4.5) {
        VV = 45;
    } else if (VVX == 4.6) {
        VV = 46;
    } else if (VVX == 4.7) {
        VV = 47;
    } else if (VVX == 4.8) {
        VV = 48;
    } else if (VVX == 4.9) {
        VV = 49;
    } else if (VVX < 5.5) {
        VV = 50;
    } else if (VVX < 6.5) {
        VV = 56;
    } else if (VVX < 7.5) {
        VV = 57;
    } else if (VVX < 8.5) {
        VV = 58;
    } else if (VVX < 9.5) {
        VV = 59;
    } else if (VVX < 10.5) {
        VV = 60;
    } else if (VVX < 11.5) {
        VV = 61;
    } else if (VVX < 12.5) {
        VV = 62;
    } else if (VVX < 13.5) {
        VV = 63;
    } else if (VVX < 14.5) {
        VV = 64;
    } else if (VVX < 15.5) {
        VV = 65;
    } else if (VVX < 16.5) {
        VV = 66;
    } else if (VVX < 17.5) {
        VV = 67;
    } else if (VVX < 18.5) {
        VV = 68;
    } else if (VVX < 19.5) {
        VV = 69;
    } else if (VVX < 20.5) {
        VV = 70;
    } else if (VVX < 21.5) {
        VV = 71;
    } else if (VVX < 22.5) {
        VV = 72;
    } else if (VVX < 23.5) {
        VV = 73;
    } else if (VVX < 24.5) {
        VV = 74;
    } else if (VVX < 25.5) {
        VV = 75;
    } else if (VVX < 26.5) {
        VV = 76;
    } else if (VVX < 27.5) {
        VV = 77;
    } else if (VVX < 28.5) {
        VV = 78;
    } else if (VVX < 29.5) {
        VV = 79;
    } else if (VVX < 35) {
        VV = 80;
    } else if (VVX < 38) {
        VV = 81;
    } else if (VVX < 43) {
        VV = 82;
    } else if (VVX < 48) {
        VV = 83;
    } else if (VVX < 53) {
        VV = 84;
    } else if (VVX < 58) {
        VV = 85;
    } else if (VVX < 63) {
        VV = 86;
    } else if (VVX < 68) {
        VV = 87;
    } else if (VVX <= 70) {
        VV = 88;
    } else {
        VV = 89;
    }
    var VVs = String(('00' + VV).slice(-2));

    if (VVX == '') {
        VVsq = "//";
    } else {
        VVsq = VVs;
    }
    document.getElementById("VVizr").innerHTML = VVsq;
    return VVsq;
}

function visina_srednjih_oblaka () {
    var kmm = document.getElementById("kmm").value; //visina podnice najnižeg oblaka [km]
    if (kmm < 0.05){
        hm = 0;
    } else if (kmm < 0.1) {
        hm = 1;
    } else if (kmm < 0.2) {
        hm = 2;
    } else if (kmm < 0.3) {
        hm = 3;
    } else if (kmm < 0.6) {
        hm = 4;
    } else if (kmm < 1) {
        hm = 5;
    } else if (kmm < 1.5) {
        hm = 6;
    } else if (kmm < 2) {
        hm = 7;
    } else if (kmm < 2.5) {
        hm = 8;
    } else if (kmm >= 2.5) {
        hm = 9;
   } else {
        hm = "/";
    }

    if (kmm == '') {
    hmq = ''
    } else {
    hmq = hm;
    }
    document.getElementById("hmizr").innerHTML = hmq;
    return hmq;
}

function visina_niskih_oblaka () {
    var kml = document.getElementById("kml").value; //visina podnice najnižeg oblaka [km]
    if (kml < 0.05){
        hl = 0;
    } else if (kml < 0.1) {
        hl = 1;
    } else if (kml < 0.2) {
        hl = 2;
    } else if (kml < 0.3) {
        hl = 3;
    } else if (kml < 0.6) {
        hl = 4;
    } else if (kml < 1) {
        hl = 5;
    } else if (kml < 1.5) {
        hl = 6;
    } else if (kml < 2) {
        hl = 7;
    } else if (kml < 2.5) {
        hl = 8;
    } else if (kml >= 2.5) {
        hl = 9;
   } else {
        hl = "/";
    }

    if (kml == '') {
    hlq = ''
    } else {
    hlq = hl;
    }
    document.getElementById("hlizr").innerHTML = hlq;
    return hlq;
}

function pnula () {
    var tbx = document.getElementById("tb").value;
    var bx = document.getElementById("b").value;
    e = 2.718282;
    if (bi1 == 1) {
    kortl = 1.333224
    }
    else if (bi1 == 2) {
    kortl = 1
    }
    else {
    kortl = 0
    }
    var cb1 = 0.000163;
    if (bi2 == 1) {
    cb2 = 0.0
    } else if (bi2 == 2) {
    cb2 = 33.09
    }  else if (bi2 == 3) {
    cb2 = 45.33
    }  else if (bi2 == 4) {
    cb2 = 15.30
    } else {
    cb2 = 49.46
    }
    tb = tbx /10;
    b = bx / 10;
    var ALFA = pk * 0.01;
    var KOS = Math.cos(2.0 * GS * 3.141593/180.0);
    var GF0 = 9.80616 * (1.-(0.0026373 * KOS)) + (0.0000059 * (Math.pow(KOS,2)));
    var GFHB = GF0 - 0.000003086 * hb + 0.000001118 * ALFA * (hb - hsr)- 0.00000688 * (1-ALFA) * (db - dbs);
    var P0 = b * kortl
    var P0_1 = P0 - (cb1 * (P0 + cb2) * tb);
    var P0_final = P0_1 + P0 * (GFHB/9.80665 - 1.0);
    var P0_final1 = (P0_final).toFixed(1);
    var P0_final2 = P0_final1 * 10;
    if (P0_final1 < 1000) {
        P0P0P0P0 = String(P0_final1 * 10);
     } else {
        P0P0 = ((P0_final1 - 1000) * 10).toFixed(0);
        P0P0P0P0 = String('0000' + P0P0).slice(-4);
       }
    document.getElementById("P0P0P0P0").innerHTML = P0P0P0P0;
    return P0P0P0P0;
}

function psmr () {
    var P0xx = pnula ()
    if (P0xx < 700) {
        P0x = P0xx + 10000
    } else {
        P0x = P0xx
    }
    var TSx = document.getElementById("tts").value;
    var TS = TSx / 10;
    var T_SMR = TS + (0.5 * hb / 100);
    var T_S = (TS + T_SMR) / 2;
    var hg = hb * 9.81;
    var RT = 286.9 * (T_S + 273.15);
    var hgRT = hg / RT;
    var k = Math.pow(e, hgRT) - 1;
    var dP = P0x * k;
    var P_hPa = P0x + dP;
    var P_hPaf = parseFloat(P_hPa).toFixed(1);
    if (P_hPa < 1000) {
          PPPP = (P_hPa * 10).toFixed(0);
     } else {
        PP = ((P_hPa - 1000) * 10).toFixed(0);
        PPPP = String('0000' + PP).slice(-4);
       }
    document.getElementById("PPPP").innerHTML = PPPP;
    return PPPP;
}
</script>
    <table>
      <tr>
        <td colspan="16" class="vrh"><b><p id="postaja"></p></b></td>
      </tr>
      <tr>
        <td colspan="16" class="vrh"><b>TERMINSKE VRIJEDNOST</b></td>
      </tr>
      <tr class="centar">
        <td class="unos">km</td>
        <td class="izracun">VV</td>
        <td class="unos">NN<sub>H</sub></td>
        <td class="unos">C<sub>H</sub></td>
        <td class="unos">NN<sub>M</sub></td>
        <td class="unos">C<sub>M</sub></td>
        <td class="unos">km<sub>M</sub></td>
        <td class="izracun">h<sub>M</sub></td>
        <td class="unos">NN<sub>L</sub></td>
        <td class="unos">C<sub>L</sub></td>
        <td class="unos">km<sub>L</sub></td>
        <td class="izracun">h<sub>L</sub></td>
        <td class="unos">dd</td>
        <td class="unos">ff</td>
        <td class="unos">DD</td>
        <td class="unos">FF</td>
      </tr>
      <tr class="centar">
        <td class="unos"><input class="unos" type="text" size="3" id="km" onblur="vidljivost ()"></td>
        <td class="izracun"><p id="VVizr"></p></td>
        <td class="unos"><input class="unos" type="text" size="3" id="nnh"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="ch"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="nnm"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="cm"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="kmm" onblur="visina_srednjih_oblaka ()"></sub></td>
        <td class="izracun"><p id="hmizr"></p></td>
        <td class="unos"><input class="unos" type="text" size="3" id="nnl"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="cl"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="kml" onblur="visina_niskih_oblaka ()"></td>
        <td class="izracun"><p id="hlizr"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="dd"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="ff"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="DD"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="FF"></td>
      </tr>
      <tr class="centar">
        <td class="unos">E</td>
        <td class="unos">E'</td>
        <td class="unos1">T<sub>w</sub></td>
        <td class="unos">T</td>
        <td class="unos">T'</td>
        <td class="izracun">T<sub>d</sub></td>
        <td class="izracun">e</td>
        <td class="izracun">U</td>
        <td class="unos">T<sub>b</sub></td>
        <td class="unos">b</td>
        <td class="izracun">P<sub>0</sub></td>
        <td class="izracun"><p id="bxxx"></p></td>
        <td class="unos">P<sub>(-3h)</sub></td>
        <td class="unos"><b>5appp</b></td>
        <td colspan="2" class="unos"><b>7wwW<sub>1</sub>W<sub>2</sub></td>
      </tr>
      <tr class="centar">
        <td class="unos"><input class="unos" type="text" size="3" id="es"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="em"></td>
        <td class="unos1"><input class="unos1" type="text" size="3" id="tw"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="tts"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="tm"></td>
        <td class="izracun">T<sub>d</sub></td>
        <td class="izracun">e</td>
        <td class="izracun">U</td>
        <td class="unos"><input class="unos" type="text" size="3" id="tb"></td>
        <td class="unos"><input class="unos" type="text" size="3" id="b" onblur="pnula ();psmr ()"></td>
        <td class="izracun"><p id="P0P0P0P0"></p></td>
        <td class="izracun"><p id="PPPP"></p></td>
        <td class="unos"><input class="unos" type="text" size="3" id="p3h" onblur="pprom ()"></td>
        <td class="unos"><b>5</b><input class="unos" type="text" size="1" id="appp"><b><p id="prom" style="display:inline">ppp</p></b></td>
        <td colspan="2" class="unos"><b>7</b><input class="unos" type="text" size="4" id="wwW1W2"></td>
      </tr>
      <tr>
        <td colspan="16" class="vrh"><b>DNEVNE VRIJEDNOST</b></td>
      </tr>
      <tr class="centar">
        <td colspan="2" class="unos"><div id="max">T<sub>X</sub></div></td>
        <td colspan="2" class="unos"><div id="min">T<sub>N</sub></div></td>
        <td colspan="2" class="unos"><div id="min5">T<sub>n5</sub></div></td>
        <td colspan="3" class="unos"><div id="oborina">R<p id="Re" style="display:inline"></div></td>
        <td colspan="1" class="unos"><div id="sss">sss</div></td>
        <td colspan="2" class="unos"><div id="r24">R<sub>24</sub></div></td>
        <td colspan="4" class="unos">S<sub>p</sub>S<sub>p</sub>S<sub>p</sub>S<sub>p</sub></td>
      </tr>
      <tr class="centar">
        <td colspan="2" class="unos"><div id="max"><input class="unos" type="text" size="3" id="tx"></div></td>
        <td colspan="2" class="unos"><input class="unos" type="text" size="3" id="tn"></td>
        <td colspan="2" class="unos"><input class="unos" type="text" size="3" id="tn5"></td>
        <td colspan="3" class="unos"><input class="unos" type="text" size="3" id="R"></p></td>
        <td colspan="1" class="unos"><input class="unos" type="text" size="3" id="sss"></td>
        <td colspan="2" class="unos"><input class="unos" type="text" size="3" id="R24"></td>
        <td colspan="4" class="unos"><input class="unos" type="text" size="18" id="spspspsp"></sub></td>
      </tr>
      <tr>
        <td colspan="16" id="synop"><div id="div2"><p id="odjeljak0"></p></div></td>
      </tr>
    </table>
  </body>
</html>
Linux za srce i dušu.

GitHub
Twitch
YouTube
Avatar
Postovi: 42
Postovi: 42
Pridružen/a: 09 ožu 2020, 19:12
Lokacija: Zagreb
Podijelio/la zahvalu: 2 puta
Primio/la zahvalu: 1 puta
Spol: M
parseInt(document.querySelector('#tts').value) mi radi.

Trebaš svugdje gdje ti je input type="text" omotati s parseInt, inače se shvaća kao string (+ radi konkatenaciju, / nema smisla, pa je rezultat NaN ~= 0)
Avatar
Site Admin
Postovi: 4639
Site Admin
Postovi: 4639
Pridružen/a: 07 ožu 2009, 17:00
Podijelio/la zahvalu: 101 puta
Primio/la zahvalu: 209 puta
Spol: M
OS: fedora 34

Na mreži
Trenutno korisnika/ca: / i 11 gostiju.