Karachi – The exchange rates of major foreign currencies with the Pakistani Rupee (PKR) in the open market have been updated today. It’s important to have up-to-date information on current exchange rates when you’re sending money home, planning a trip abroad or making international payments.
The following table contrasts the buying and selling rates for this major global currency with the US Dollar.Below are shown the buying and selling rates of the US Dollar in relation to the other top global currencies, including the Saudi Riyal, the UAE Dirham and others.
${item.code} |
${item.buy.toFixed(2)} |
${item.sell.toFixed(2)} |
`;
tbody.appendChild(tr);
});
}
function filterForexTable() {
const query = document.getElementById('forex-search').value.toLowerCase().trim();
const filtered = forexData.filter(item =>
item.code.toLowerCase().includes(query) ||
item.name.toLowerCase().includes(query)
);
renderTableData(filtered);
}
function switchForexTab(tabName) {
const tabButtons = document.querySelectorAll('.forex-tab-btn');
const tableView = document.getElementById('forex-table-view');
const graphView = document.getElementById('forex-graph-view');
const faqView = document.getElementById('forex-faq-view');
tabButtons.forEach(btn => btn.classList.remove('active'));
tableView.classList.remove('active');
graphView.classList.remove('active');
faqView.classList.remove('active');
if (tabName === 'table') {
tabButtons[0].classList.add('active');
tableView.classList.add('active');
} else if (tabName === 'graph') {
tabButtons[1].classList.add('active');
graphView.classList.add('active');
if (window.myForexChart) {
window.myForexChart.update();
}
} else if (tabName === 'faq') {
tabButtons[2].classList.add('active');
faqView.classList.add('active');
}
}
function toggleFaq(button) {
const item = button.parentElement;
item.classList.toggle('open');
}
function updateFaqData() {
const usd = forexData.find(d => d.code === "USD");
const sar = forexData.find(d => d.code === "SAR");
const gbp = forexData.find(d => d.code === "GBP");
if (usd) {
document.getElementById('faq-usd-buy').innerText = usd.buy.toFixed(2);
document.getElementById('faq-usd-sell').innerText = usd.sell.toFixed(2);
}
if (sar) {
document.getElementById('faq-sar-buy').innerText = sar.buy.toFixed(2);
document.getElementById('faq-sar-sell').innerText = sar.sell.toFixed(2);
}
if (gbp) {
document.getElementById('faq-gbp-buy').innerText = gbp.buy.toFixed(2);
document.getElementById('faq-gbp-sell').innerText = gbp.sell.toFixed(2);
}
}
function initForexWidget() {
renderTableData(forexData);
updateFaqData();
const chartCanvas = document.getElementById('forexChart');
if (chartCanvas && typeof Chart !== 'undefined') {
const ctx = chartCanvas.getContext('2d');
const visualGroup = forexData.slice(0, 8);
const chartLabels = visualGroup.map(d => d.code);
const buyingData = visualGroup.map(d => d.buy);
const sellingData = visualGroup.map(d => d.sell);
window.myForexChart = new Chart(ctx, {
type: 'bar',
data: {
labels: chartLabels,
datasets: [
{
label: 'Buying',
data: buyingData,
backgroundColor: 'rgba(6, 95, 70, 0.85)',
borderColor: '#065f46',
borderWidth: 1,
borderRadius: 4
},
{
label: 'Selling',
data: sellingData,
backgroundColor: 'rgba(245, 158, 11, 0.85)',
borderColor: '#f59e0b',
borderWidth: 1,
borderRadius: 4
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top',
labels: { font: { family: "'Poppins', sans-serif", size: 11 } }
}
},
scales: {
y: {
beginAtZero: false,
ticks: { font: { family: "'Poppins', sans-serif", size: 10 } }
},
x: {
ticks: { font: { family: "'Poppins', sans-serif", size: 10, weight: 600 } }
}
}
}
});
}
}
if (document.documentState === 'loading') {
document.addEventListener('DOMContentLoaded', initForexWidget);
} else {
initForexWidget();
}