This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
FunctionProject/scripts/execute-function/convertCurrency_DOM.js

20 lines
859 B
JavaScript
Raw Normal View History

import { convertCurrency } from '../functions/fonctions_principales/convertCurrency_Function.js';
import { isEmptyValue } from '../functions/fonctions_annexes/isEmptyValue_Function.js';
$(function () {
$("#convertCurrencyForm").submit(() => {
event.preventDefault();
let value = $('#value').val();
const currencyOfTheValue = $("#currencyOfTheValue option:selected").val();
const currencyAfter = $("#currencyAfter option:selected").val();
if(isEmptyValue(value) || isNaN(parseFloat(value))) {
$('.rateDate').html('');
$('.results').html(emptyMessageError);
}
else {
const url = 'https://api.exchangeratesapi.io/latest?base=' + currencyOfTheValue;
value = parseFloat(value);
convertCurrency(value, currencyAfter, url);
}
});
});