convertValuti.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>convert</title>
  6. </head>
  7. <body>
  8. <input type="input" name="convert" id="convert">
  9. <p><b></b></p>
  10. <div id="params">
  11. <input type="checkbox" name="option1" value="a1" id="i1">UAH
  12. <input type="checkbox" name="option2" value="a2" id="i2">USD
  13. <input type="checkbox" name="option3" value="a3" id="i3">CNY
  14. <input type="checkbox" name="option4" value="a4" id="i4">CHF
  15. <input type="checkbox" name="option5" value="a5" id='i5'>EUR
  16. </div>
  17. <p><input type="button" name="btn" id="btn" value="Press" onclick="conv()"></p>
  18. <div id="hid">
  19. </div>
  20. <script>
  21. function conv(){
  22. if(i1.checked==true){
  23. while (hid.hasChildNodes()) {
  24. hid.removeChild(hid.firstChild);
  25. }
  26. fetch('https://open.er-api.com/v6/latest/UAH')
  27. .then(r=>r.json())
  28. .then(data=>{
  29. let p=document.createElement('p');
  30. p.innerHTML='USD: '+'$'+data.rates.USD*convert.value;
  31. hid.append(p);
  32. });
  33. fetch('https://open.er-api.com/v6/latest/UAH')
  34. .then(r=>r.json())
  35. .then(data=>{
  36. let p=document.createElement('p');
  37. p.innerHTML='CNY: '+data.rates.CNY*convert.value;
  38. hid.append(p);
  39. });
  40. fetch('https://open.er-api.com/v6/latest/UAH')
  41. .then(r=>r.json())
  42. .then(data=>{
  43. let p=document.createElement('p');
  44. p.innerHTML='CHF: '+data.rates.CHF*convert.value;
  45. hid.append(p);
  46. });
  47. fetch('https://open.er-api.com/v6/latest/UAH')
  48. .then(r=>r.json())
  49. .then(data=>{
  50. let p=document.createElement('p');
  51. p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
  52. hid.append(p);
  53. });
  54. }
  55. if(i2.checked==true){
  56. while (hid.hasChildNodes()) {
  57. hid.removeChild(hid.firstChild);
  58. }
  59. fetch('https://open.er-api.com/v6/latest/USD')
  60. .then(r=>r.json())
  61. .then(data=>{
  62. let p=document.createElement('p');
  63. p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
  64. hid.append(p);
  65. });
  66. fetch('https://open.er-api.com/v6/latest/USD')
  67. .then(r=>r.json())
  68. .then(data=>{
  69. let p=document.createElement('p');
  70. p.innerHTML='CNY: '+data.rates.CNY*convert.value;
  71. hid.append(p);
  72. });
  73. fetch('https://open.er-api.com/v6/latest/USD')
  74. .then(r=>r.json())
  75. .then(data=>{
  76. let p=document.createElement('p');
  77. p.innerHTML='CHF: '+data.rates.CHF*convert.value;
  78. hid.append(p);
  79. });
  80. fetch('https://open.er-api.com/v6/latest/USD')
  81. .then(r=>r.json())
  82. .then(data=>{
  83. let p=document.createElement('p');
  84. p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
  85. hid.append(p);
  86. });
  87. }
  88. if(i3.checked==true){
  89. while (hid.hasChildNodes()) {
  90. hid.removeChild(hid.firstChild);
  91. }
  92. fetch('https://open.er-api.com/v6/latest/CNY')
  93. .then(r=>r.json())
  94. .then(data=>{
  95. let p=document.createElement('p');
  96. p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
  97. hid.append(p);
  98. });
  99. fetch('https://open.er-api.com/v6/latest/CNY')
  100. .then(r=>r.json())
  101. .then(data=>{
  102. let p=document.createElement('p');
  103. p.innerHTML='USD: '+data.rates.USD*convert.value;
  104. hid.append(p);
  105. });
  106. fetch('https://open.er-api.com/v6/latest/CNY')
  107. .then(r=>r.json())
  108. .then(data=>{
  109. let p=document.createElement('p');
  110. p.innerHTML='CHF: '+data.rates.CHF*convert.value;
  111. hid.append(p);
  112. });
  113. fetch('https://open.er-api.com/v6/latest/CNY')
  114. .then(r=>r.json())
  115. .then(data=>{
  116. let p=document.createElement('p');
  117. p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
  118. hid.append(p);
  119. });
  120. }
  121. if(i4.checked==true){
  122. while (hid.hasChildNodes()) {
  123. hid.removeChild(hid.firstChild);
  124. }
  125. fetch('https://open.er-api.com/v6/latest/CHF')
  126. .then(r=>r.json())
  127. .then(data=>{
  128. let p=document.createElement('p');
  129. p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
  130. hid.append(p);
  131. });
  132. fetch('https://open.er-api.com/v6/latest/CHF')
  133. .then(r=>r.json())
  134. .then(data=>{
  135. let p=document.createElement('p');
  136. p.innerHTML='CNY: '+data.rates.CNY*convert.value;
  137. hid.append(p);
  138. });
  139. fetch('https://open.er-api.com/v6/latest/CHF')
  140. .then(r=>r.json())
  141. .then(data=>{
  142. let p=document.createElement('p');
  143. p.innerHTML='USD: '+data.rates.USD*convert.value;
  144. hid.append(p);
  145. });
  146. fetch('https://open.er-api.com/v6/latest/CHF')
  147. .then(r=>r.json())
  148. .then(data=>{
  149. let p=document.createElement('p');
  150. p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
  151. hid.append(p);
  152. });
  153. }
  154. if(i5.checked==true){
  155. while (hid.hasChildNodes()) {
  156. hid.removeChild(hid.firstChild);
  157. }
  158. fetch('https://open.er-api.com/v6/latest/EUR')
  159. .then(r=>r.json())
  160. .then(data=>{
  161. let p=document.createElement('p');
  162. p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
  163. hid.append(p);
  164. });
  165. fetch('https://open.er-api.com/v6/latest/EUR')
  166. .then(r=>r.json())
  167. .then(data=>{
  168. let p=document.createElement('p');
  169. p.innerHTML='CNY: '+data.rates.CNY*convert.value;
  170. hid.append(p);
  171. });
  172. fetch('https://open.er-api.com/v6/latest/EUR')
  173. .then(r=>r.json())
  174. .then(data=>{
  175. let p=document.createElement('p');
  176. p.innerHTML='CHF: '+data.rates.CHF*convert.value;
  177. hid.append(p);
  178. });
  179. fetch('https://open.er-api.com/v6/latest/EUR')
  180. .then(r=>r.json())
  181. .then(data=>{
  182. let p=document.createElement('p');
  183. p.innerHTML='USD: '+Number(data.rates.USD).toFixed(3)*convert.value;
  184. hid.append(p);
  185. });
  186. }
  187. }
  188. //let urls=['UAH','USD','CNY','CHF','EUR'];
  189. </script>
  190. </body>
  191. </html>