<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
label {
display: block;
margin-top: 10px;
}
h3 {
margin-top: 20px;
}
</style>
<body>
<h1>Currency and Date Formatter</h1>
<label for="amount">Enter Amount:</label>
<input type="number" id="amount" value="1234567.89" step="0.01">
<br><br>
<label for="date">Select Date:</label>
<input type="date" id="date">
<br><br>
<label for="locale">Select Locale:</label>
<select id="locale">
<option value="en-US">en-US</option>
<option value="en-IN">en-IN</option>
<option value="ja-JP">ja-JP</option>
<option value="fr-FR">fr-FR</option>
<option value="de-DE">de-DE</option>
</select>
<br><br>
<div>
<h3>Formatted Output</h3>
<p><strong>Selected Locale:</strong> <span id="selected-locale">-</span></p>
<p><strong>Formatted Amount:</strong> <span id="formatted-amount">-</span></p>
<p><strong>Formatted Date:</strong> <span id="formatted-date">-</span></p>
</div>
<script>
const currencyLocales = [
{ locale: "en-US", currency: "USD" },
{ locale: "en-IN", currency: "INR" },
{ locale: "ja-JP", currency: "JPY" },
{ locale: "fr-FR", currency: "EUR" },
{ locale: "de-DE", currency: "EUR" }
];
const amountInput = document.getElementById('amount');
const dateInput = document.getElementById('date');
const localeSelect = document.getElementById('locale');
const selectedLocaleDisplay = document.getElementById('selected-locale');
const formattedAmountDisplay = document.getElementById('formatted-amount');
const formattedDateDisplay = document.getElementById('formatted-date');
function updateOutput() {
const amount = parseFloat(amountInput.value) || 0;
const dateValue = dateInput.value ? new Date(dateInput.value) : new Date();
const selectedLocale = localeSelect.value;
const selectedCurrency = (currencyLocales.find(item => item.locale === selectedLocale) || {}).currency || "USD";
const formattedAmount = amount.toLocaleString(selectedLocale, {
style: 'currency',
currency: selectedCurrency
});
const formattedDate = dateValue.toLocaleDateString(selectedLocale);
selectedLocaleDisplay.textContent = selectedLocale;
formattedAmountDisplay.textContent = formattedAmount;
formattedDateDisplay.textContent = formattedDate;
}
amountInput.addEventListener('input', updateOutput);
dateInput.addEventListener('input', updateOutput);
localeSelect.addEventListener('change', updateOutput);
dateInput.value = new Date().toISOString().substr(0, 10);
updateOutput();
</script>
</body>