Counter minimum, new in the html and all other code |
Counter minimum, new in the html and all other code |
Osku |
Mar 3 2020, 02:23 PM
Post
#1
|
Group: Members Posts: 3 Joined: 3-March 20 Member No.: 27,217 |
Hello! I am new to all code and studying some beginner course atm.
So, I want to add a strip of code that doesn't allow negative values in the printed out text. Here is what I have so far. <html> <head> <center> <meta charset="utf-8"/> <title>Pressavaali laskuri</title> Äänilaskuri <br> <br> <nav> </head> <body> <button type="button" onclick="lisaa();"> lisää äänen </button> click to vote <!the first button increases the the total value.> <br> <button type="button" onclick="vahenna();"> vähentää äänen </button> click to veto <!the second button decreases the the total value.> <h1 id="laskuri1"> 0 </h1> <script> var clicks = 0; function lisaa(){ clicks++; document.getElementById("laskuri1").innerHTML = clicks; //// +1 votes } function vahenna(){ clicks-- document.getElementById("laskuri1").innerHTML = clicks; //// -1 votes } </script> </body> </center> </html> I'd appreciate any help, I am kinda lost here, couldn't find this info, due the lack of knowledge in search words |
Lo-Fi Version | Time is now: 26th April 2024 - 11:35 AM |