File size: 3,303 Bytes
098ffc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Currency Converter</title> </head> <body> 💱 Currency Converter 
by ☕ CofAI
<form>
    <p></p>
    <p></p> 
    <label for="amount">💰 Sum:</label>
    <input type="number" id="amount" name="amount" min="0">
    <br><br>
    <p></p>
    <label for="from">🪙 From currency:</label>
    <select id="from" name="from">
        <option value="RUB">₽ (Russian ruble)</option>
        <option value="USD">$ (UWB dollar)</option>
        <option value="EUR">€ (Euro)</option>
        <option value="JPY">¥ (Japanese yen)</option>
    </select>
    <br><br>
    
    <label for="to">💸 To currency:</label>
    <select id="to" name="to">
        <option value="RUB">₽ (Russian ruble)</option>
        <option value="USD">$ (UWB dollar)</option>
        <option value="EUR">€ (Euro)</option>
        <option value="JPY">¥ (Japanese yen)</option>
    </select>
    <br><br>
    <p></p>
    <input type="button" value="✅️ Convert" onclick="convertCurrency()">
</form>
<p></p>
<h2>♾️ Result:</h2>
<div id="result"></div>

<script>
    function convertCurrency() {
        var amount = parseFloat(document.getElementById("amount").value);
        var fromCurrency = document.getElementById("from").value;
        var toCurrency = document.getElementById("to").value;
        var result = 0;

        // Курс валют можно добавить здесь или получать из внешнего источника

        if (fromCurrency === "RUB" && toCurrency === "USD") {
            result = amount / 90,40; // Примерный курс
        } else if (fromCurrency === "RUB" && toCurrency === "EUR") {
            result = amount / 100,58; // Примерный курс
        } else if (fromCurrency === "RUB" && toCurrency === "JPY") {
            result = amount / 0,64; // Примерный курс
        } else if (fromCurrency === "USD" && toCurrency === "RUB") {
            result = amount * 90,40; // Примерный курс
        } else if (fromCurrency === "USD" && toCurrency === "EUR") {
            result = amount * 0,90; // Примерный курс
        } else if (fromCurrency === "USD" && toCurrency === "JPY") {
            result = amount * 140,45; // Примерный курс
        } else if (fromCurrency === "EUR" && toCurrency === "RUB") {
            result = amount * 100,57; // Примерный курс
        } else if (fromCurrency === "EUR" && toCurrency === "USD") {
            result = amount * 1,11; // Примерный курс
        } else if (fromCurrency === "EUR" && toCurrency === "JPY") {
            result = amount * 156,26; // Примерный курс
        } else if (fromCurrency === "JPY" && toCurrency === "RUB") {
            result = amount * 0,64; // Примерный курс
        } else if (fromCurrency === "JPY" && toCurrency === "USD") {
            result = amount * 0,0071; // Примерный курс
        } else if (fromCurrency === "JPY" && toCurrency === "EUR") {
            result = amount * 0,0064; // Примерный курс
        } else {
            result = amount;
        }

        document.getElementById("result").innerHTML = result.toFixed(2);
    }
</script>
</body> </html>