Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="utf-8">
- <title>OGŁOSZENIA</title>
- </head>
- <body>
- <form>
- <h1>Ile kosztuje ogłowszenie?</h1>
- <br>
- <p>podaj liczbę ogłoszeń:</p>
- <input type="number" name="ile_ogloszen">
- <br>
- <input type="checkbox" name="box"> Policz upust na newsletter
- <br>
- <input type="button" class="button" value="Oblicz">
- <div id="pole"></div>
- </form>
- <script>
- var box = document.querySelector("input[name=box]");
- var ile_ogloszen = document.querySelector("input[name=ile_ogloszen]");
- var x = document.getElementsByClassName("button");
- var cena = 0;
- function koszt() {
- if (ile_ogloszen.value<=50){
- cena = ile_ogloszen.value*2;
- } else {
- cena = ile_ogloszen.value;
- }
- if (box.checked == true){
- cena = cena;
- } else {
- cena = cena - ile_ogloszen.value*0.2;
- }
- document.getElementById("pole").innerHTML = cena;
- }
- x[0].onclick = koszt;
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement