Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <p>Jarosław Gryczan</p>
- <p>47184</p>
- <input type="text" id="liczba1">
- <select onChange="compare()" id="operacja">
- <option value="1">==</option>
- <option value="2">===</option>
- <option value="3">!=</option>
- <option value="4">!==</option>
- </select>
- <input type="text" id="liczba2">
- <p id="result"></p>
- <script>
- function compare()
- {
- var operacja = document.getElementById("operacja");
- var index = operacja.options[operacja.selectedIndex].value;
- var liczba1 = document.getElementById("liczba1").value;
- var liczba2 = parseFloat(document.getElementById("liczba2").value);
- var result = document.getElementById("result");
- switch(index) {
- case '1':
- if(liczba1==liczba2){
- result.innerHTML = true;
- }else{
- result.innerHTML = false;
- }
- break;
- case '2':
- if(liczba1===liczba2){
- result.innerHTML = true;
- }else{
- result.innerHTML = false;
- }
- break;
- case '3':
- if(liczba1!=liczba2){
- result.innerHTML = true;
- }else{
- result.innerHTML = false;
- }
- break;
- case '4':
- if(liczba1!==liczba2){
- result.innerHTML = true;
- }else{
- result.innerHTML = false;
- }
- break;
- default:
- // code block
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement