123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>convert</title>
- </head>
- <body>
- <input type="input" name="convert" id="convert">
- <p><b></b></p>
- <div id="params">
- <input type="checkbox" name="option1" value="a1" id="i1">UAH
- <input type="checkbox" name="option2" value="a2" id="i2">USD
- <input type="checkbox" name="option3" value="a3" id="i3">CNY
- <input type="checkbox" name="option4" value="a4" id="i4">CHF
- <input type="checkbox" name="option5" value="a5" id='i5'>EUR
- </div>
- <p><input type="button" name="btn" id="btn" value="Press" onclick="conv()"></p>
- <div id="hid">
-
- </div>
- <script>
- function conv(){
- if(i1.checked==true){
- while (hid.hasChildNodes()) {
- hid.removeChild(hid.firstChild);
- }
- fetch('https://open.er-api.com/v6/latest/UAH')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='USD: '+'$'+data.rates.USD*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/UAH')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CNY: '+data.rates.CNY*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/UAH')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CHF: '+data.rates.CHF*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/UAH')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
- hid.append(p);
- });
- }
- if(i2.checked==true){
- while (hid.hasChildNodes()) {
- hid.removeChild(hid.firstChild);
- }
- fetch('https://open.er-api.com/v6/latest/USD')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/USD')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CNY: '+data.rates.CNY*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/USD')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CHF: '+data.rates.CHF*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/USD')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
- hid.append(p);
- });
- }
- if(i3.checked==true){
- while (hid.hasChildNodes()) {
- hid.removeChild(hid.firstChild);
- }
- fetch('https://open.er-api.com/v6/latest/CNY')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/CNY')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='USD: '+data.rates.USD*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/CNY')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CHF: '+data.rates.CHF*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/CNY')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
- hid.append(p);
- });
- }
- if(i4.checked==true){
- while (hid.hasChildNodes()) {
- hid.removeChild(hid.firstChild);
- }
- fetch('https://open.er-api.com/v6/latest/CHF')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/CHF')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CNY: '+data.rates.CNY*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/CHF')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='USD: '+data.rates.USD*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/CHF')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='EUR: '+Number(data.rates.EUR).toFixed(3)*convert.value;
- hid.append(p);
- });
- }
- if(i5.checked==true){
- while (hid.hasChildNodes()) {
- hid.removeChild(hid.firstChild);
- }
- fetch('https://open.er-api.com/v6/latest/EUR')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='UAH: '+'$'+data.rates.UAH*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/EUR')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CNY: '+data.rates.CNY*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/EUR')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='CHF: '+data.rates.CHF*convert.value;
- hid.append(p);
- });
- fetch('https://open.er-api.com/v6/latest/EUR')
- .then(r=>r.json())
- .then(data=>{
- let p=document.createElement('p');
- p.innerHTML='USD: '+Number(data.rates.USD).toFixed(3)*convert.value;
- hid.append(p);
- });
- }
- }
- //let urls=['UAH','USD','CNY','CHF','EUR'];
- </script>
- </body>
- </html>
|