1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <p id="wypis"></p> <script> var i=prompt("Podaj poczatek zakresu"); var koniec=prompt("Podaj koniec zakresu"); var napis=""; for(i;i<=koniec;i++) napis=napis+i+" "; document.getElementById('wypis').innerHTML=napis; </script> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function zakres() { //wersja alternatywna var x=prompt("podaj początek zakresu"); var y=prompt("podaj koniec zakresu"); var c=y-x; var i=0; const tab=[c]; { for(x;x<=y;x++) { tab[i]=x; i++; } } document.getElementById('paragraf').innerHTML=tab; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8" /> <script type="text/javascript"> function spr() { if(document.getElementById('kabriolet').checked) opcja = document.getElementById('kabriolet').value; else if(document.getElementById('kombi').checked) opcja = document.getElementById('kombi').value; else opcja = document.getElementById('hatchback').value; document.getElementById('wynik').innerHTML = "Wybrane przez Ciebie nadwozie to: "+opcja; } </script> </head> <body onload="spr()"> <form></form><label><input onchange="spr()" type="radio" name="nadwozie" checked value="kabriolet" id="kabriolet" />Kabriolet</label><br /> <label><input onchange="spr()" type="radio" name="nadwozie" value="hatchback" id="hatchback"/>Hatchback</label><br /> <label><input onchange="spr()" type="radio" name="nadwozie" value="kombi" id="kombi" />Kombi</label><br /> </form> <div id="wynik"></div> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Pizzeria</title> <script type="text/javascript"> function oblicz() { if(document.getElementById("nazwaid").checked == true) document.getElementById('komunikat').innerHTML="Dowieziemy za darmo" else {var liczba=document.getElementById('ile').value; wynik=liczba*2; document.getElementById('komunikat').innerHTML="Dowóz będzie Cię kosztował " + wynik+ " złotych"; document.getElementById('komunikat2').innerHTML= typeof wynik;} } </script> </head> <body> <h3>Oblicz koszt dostawy</h3> <form name="formularz"> <label><input type="checkbox" name="nazwa" id="nazwaid" value="wartość" />Jestem z Zielonej Góry</label> <!-- nazwa - słuzy do tworzenia zmiennej value - opis czekbox-a label - powoduje że można kliknć w napis żeby zaznaczyć --> <p>albo</p> Podaj liczbę kilometrów od Zielonej Góry: <input type="number" id="ile"><br> </form> <input type="submit" value="Oblicz" onclick="oblicz()"> <div id='komunikat'></div> <div id='komunikat2'></div> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<!DOCTYPE html> <html> <head> <title>wesele</title> <meta charset="utf-8"> </head> <body> <h1>Ile będzie kosztowało moje wesele</h1> <form> <div>Podaj liczbę gości<input type="number" id="ile"></div> <div>Wesele z poprawinami<input type="checkbox" id="poprawiny" value="poprawiny" name=""></div> </form> <button type="button" onclick="oblicz()">Oblicz</button> <p id="obliczenia"></p> <script type="text/javascript"> function oblicz() { var ile=document.getElementById('ile').value; document.getElementById("obliczenia").innerHTML="Koszt Twojego wesela to "+100*ile+" złotych"; if(document.getElementById("poprawiny").checked) document.getElementById("obliczenia").innerHTML="Koszt Twojego wesela to "+(100*ile+100*ile*0.3)+" złotych"; } </script> </body> </html> |