Advertisement
Guest User

Untitled

a guest
May 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <input id="input1" onkeyup="fn1()" />
  2. <input id="input2" />
  3. <input id="input3" />
  4. <select id="select">
  5. <option value="+">+</option>
  6. <option value="-">-</option>
  7. <option value="/">/</option>
  8. <option value="*">*</option>
  9. </select>
  10. <input type="button" onclick="sum()" value="dfsdf">
  11.  
  12. <script>
  13. function fn1() {
  14. var input1 = document.getElementById("input1");
  15. var input2 = document.getElementById("input2");
  16.  
  17. input2.value = input1.value
  18. }
  19.  
  20. function sum() {
  21. var input1 = document.getElementById("input1");
  22. var input2 = document.getElementById("input2");
  23. var input3 = document.getElementById("input3");
  24. var select = document.getElementById("select");
  25.  
  26. if(select.value == "+" )
  27. {
  28. input3.value = +input1.value + +input2.value
  29. }
  30.  
  31.  
  32. if(select.value == "*") {
  33. input3.value = +input1.value * +input2.value;
  34. }
  35. if(select.value == "/"){
  36. input3.value = +input1.value / +input2.value;
  37. }
  38.  
  39. input3.value = calc()
  40.  
  41.  
  42. //alert(select.value)
  43.  
  44. }
  45.  
  46. function calc() {
  47. return Math.sqrt(Math.sqrt(5)) + Math.pow(10, 2);
  48. }
  49.  
  50.  
  51. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement