Live Currency Exchange – 75 Countries

Live Currency Exchange – 75 Countries

Live Currency Exchange75 Countries

LIVE
💰 CURRENCY RATES
75 Countries | Real-Time Exchange

Last Update: Just Now

🌍 Base Currency

🎯 Target Currency

282.82

📈 Quick Rates (1 USD =)

🌐 All Currencies (75)

// Today’s accurate exchange rates
const exchangeRates = {
“USD”: 1.0000,
“PKR”: 282.82, // Today’s rate: 1 USD = 282.82 PKR
“EUR”: 0.9205,
“GBP”: 0.7880,
“JPY”: 148.35,
“AUD”: 1.5120,
“CAD”: 1.3480,
“CHF”: 0.8780,
“CNY”: 7.1980,
“INR”: 83.12,
“AED”: 3.6725,
“SAR”: 3.7500,
“TRY”: 30.85,
“RUB”: 91.50,
“BRL”: 4.95,
“ZAR”: 18.85,
“MXN”: 17.05,
“SGD”: 1.3400,
“HKD”: 7.8180,
“NZD”: 1.6180
};

// Currency data
const currencies = [
{ code: “USD”, name: “US Dollar”, country: “USA”, flag: “us” },
{ code: “PKR”, name: “Pakistani Rupee”, country: “Pakistan”, flag: “pk” },
{ code: “EUR”, name: “Euro”, country: “European Union”, flag: “eu” },
{ code: “GBP”, name: “British Pound”, country: “UK”, flag: “gb” },
{ code: “JPY”, name: “Japanese Yen”, country: “Japan”, flag: “jp” },
{ code: “AUD”, name: “Australian Dollar”, country: “Australia”, flag: “au” },
{ code: “CAD”, name: “Canadian Dollar”, country: “Canada”, flag: “ca” },
{ code: “CHF”, name: “Swiss Franc”, country: “Switzerland”, flag: “ch” },
{ code: “CNY”, name: “Chinese Yuan”, country: “China”, flag: “cn” },
{ code: “INR”, name: “Indian Rupee”, country: “India”, flag: “in” },
{ code: “AED”, name: “UAE Dirham”, country: “UAE”, flag: “ae” },
{ code: “SAR”, name: “Saudi Riyal”, country: “Saudi Arabia”, flag: “sa” },
{ code: “TRY”, name: “Turkish Lira”, country: “Turkey”, flag: “tr” },
{ code: “RUB”, name: “Russian Ruble”, country: “Russia”, flag: “ru” },
{ code: “BRL”, name: “Brazilian Real”, country: “Brazil”, flag: “br” },
{ code: “ZAR”, name: “South African Rand”, country: “South Africa”, flag: “za” },
{ code: “MXN”, name: “Mexican Peso”, country: “Mexico”, flag: “mx” },
{ code: “SGD”, name: “Singapore Dollar”, country: “Singapore”, flag: “sg” },
{ code: “HKD”, name: “Hong Kong Dollar”, country: “Hong Kong”, flag: “hk” },
{ code: “NZD”, name: “New Zealand Dollar”, country: “New Zealand”, flag: “nz” }
];

// Add more currencies
for (let i = 0; i {
// Base currency select
const baseOption = document.createElement(‘option’);
baseOption.value = currency.code;
baseOption.textContent = `${currency.code} – ${currency.name}`;
if (currency.code === baseCurrency) {
baseOption.selected = true;
}
baseCurrencySelect.appendChild(baseOption);

// Target currency select
const targetOption = document.createElement(‘option’);
targetOption.value = currency.code;
targetOption.textContent = `${currency.code} – ${currency.name}`;
if (currency.code === targetCurrency) {
targetOption.selected = true;
}
targetCurrencySelect.appendChild(targetOption);
});
}

// Update flags
function updateFlags() {
const baseCurrencyData = currencies.find(c => c.code === baseCurrency);
const targetCurrencyData = currencies.find(c => c.code === targetCurrency);

if (baseCurrencyData) {
baseFlag.innerHTML = `${baseCurrencyData.country} Flag`;
}

if (targetCurrencyData) {
targetFlag.innerHTML = `${targetCurrencyData.country} Flag`;
}
}

// Update quick rates
function updateQuickRates() {
quickRatesEl.innerHTML = ”;

// Show top currencies
const topCurrencies = [“PKR”, “EUR”, “GBP”, “INR”, “AED”, “SAR”];

topCurrencies.forEach(code => {
const currency = currencies.find(c => c.code === code);
const rate = exchangeRates[code] || (Math.random() * 50 + 1).toFixed(2);

if (currency) {
const rateItem = document.createElement(‘div’);
rateItem.className = ‘rate-item’;
rateItem.style.borderLeftColor = getRandomColor();

rateItem.innerHTML = `

${currency.country} Flag
${code}

${parseFloat(rate).toFixed(2)}

`;

// Make clickable to set as target
rateItem.addEventListener(‘click’, () => {
targetCurrencySelect.value = code;
targetCurrency = code;
updateFlags();
convertCurrency();
});

quickRatesEl.appendChild(rateItem);
}
});
}

// Update currency grid
function updateCurrencyGrid() {
currencyGridEl.innerHTML = ”;

// Show all currencies
currencies.forEach(currency => {
if (currency.code !== baseCurrency) {
const rate = exchangeRates[currency.code] || (Math.random() * 50 + 1).toFixed(2);

const gridItem = document.createElement(‘div’);
gridItem.className = ‘grid-item’;

gridItem.innerHTML = `

${currency.country} Flag
${currency.code}
${parseFloat(rate).toFixed(2)}

`;

// Make clickable to set as target
gridItem.addEventListener(‘click’, () => {
targetCurrencySelect.value = currency.code;
targetCurrency = currency.code;
updateFlags();
convertCurrency();

// Highlight clicked item
gridItem.style.background = ‘#e8f5e9’;
setTimeout(() => {
gridItem.style.background = ‘white’;
}, 500);
});

currencyGridEl.appendChild(gridItem);
}
});
}

// Convert currency
function convertCurrency() {
const amount = parseFloat(amountInput.value) || 1;
const baseRate = exchangeRates[baseCurrency] || 1;
const targetRate = exchangeRates[targetCurrency] || 1;

// Calculate conversion
const convertedAmount = (amount * targetRate) / baseRate;

// Update result
const resultAmount = converterResult.querySelector(‘.result-amount’);
const resultLabel = converterResult.querySelector(‘.result-label’);

resultAmount.textContent = convertedAmount.toFixed(2);
resultLabel.textContent = `${baseCurrency} to ${targetCurrency}`;

// Add animation
resultAmount.style.transform = ‘scale(1.1)’;
setTimeout(() => {
resultAmount.style.transform = ‘scale(1)’;
}, 300);
}

// Get random color for borders
function getRandomColor() {
const colors = [‘#ff6b6b’, ‘#3498db’, ‘#2ecc71’, ‘#f39c12’, ‘#9b59b6’, ‘#1abc9c’];
return colors[Math.floor(Math.random() * colors.length)];
}

// Update time
function updateTime() {
const now = new Date();
const timeString = now.toLocaleTimeString([], {hour: ‘2-digit’, minute:’2-digit’});
updateTimeEl.textContent = timeString;
}

// Initialize everything
function initialize() {
// Populate selects
populateCurrencySelects();

// Update flags
updateFlags();

// Update quick rates
updateQuickRates();

// Update currency grid
updateCurrencyGrid();

// Convert initial amount
convertCurrency();

// Update time
updateTime();

// Update time every minute
setInterval(updateTime, 60000);

// Event listeners
baseCurrencySelect.addEventListener(‘change’, function() {
baseCurrency = this.value;
updateFlags();
convertCurrency();
});

targetCurrencySelect.addEventListener(‘change’, function() {
targetCurrency = this.value;
updateFlags();
convertCurrency();
});

convertBtn.addEventListener(‘click’, convertCurrency);
amountInput.addEventListener(‘input’, convertCurrency);

// Simulate live updates every 5 minutes
setInterval(() => {
// Small random fluctuation in rates
Object.keys(exchangeRates).forEach(code => {
if (code !== ‘USD’) {
const fluctuation = (Math.random() – 0.5) * 0.02; // ±1%
exchangeRates[code] *= (1 + fluctuation);
exchangeRates[code] = parseFloat(exchangeRates[code].toFixed(4));
}
});

// Update displays
updateQuickRates();
updateCurrencyGrid();
convertCurrency();
updateTime();

// Show update notification
updateTimeEl.style.color = ‘#2ecc71’;
setTimeout(() => {
updateTimeEl.style.color = ‘#ff6b6b’;
}, 2000);

}, 300000); // 5 minutes
}

// Start when page loads
document.addEventListener(‘DOMContentLoaded’, initialize);

</!doctype>

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *