|
@@ -10,18 +10,21 @@ fetch('https://open.er-api.com/v6/latest/USD')
|
|
|
const ratesForm = document.forms.rates
|
|
|
const firstField = ratesForm.first_field
|
|
|
const secondField = ratesForm.second_field
|
|
|
+ const firstList = ratesForm.first_list
|
|
|
+ const secondList = ratesForm.second_list
|
|
|
+
|
|
|
|
|
|
for (const key in currencyRates) {
|
|
|
const newOption = new Option(key, currencyRates[key])
|
|
|
- ratesForm.first_list.append(newOption)
|
|
|
- ratesForm.second_list.append(newOption.cloneNode(true))
|
|
|
+ firstList.append(newOption)
|
|
|
+ secondList.append(newOption.cloneNode(true))
|
|
|
}
|
|
|
|
|
|
ratesForm.addEventListener("input", (event) => {
|
|
|
const actionEl = event.target
|
|
|
|
|
|
- const firstCurrency = parseFloat(ratesForm.first_list.value)
|
|
|
- const secondCurrency = parseFloat(ratesForm.second_list.value)
|
|
|
+ const firstCurrency = parseFloat(firstList.value)
|
|
|
+ const secondCurrency = parseFloat(secondList.value)
|
|
|
|
|
|
const firstAmount = parseFloat(firstField.value)
|
|
|
const secondAmount = parseFloat(secondField.value)
|