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/convertDistance_DOM.js

18 lines
802 B
JavaScript
Raw Normal View History

import { convertDistance } from '../functions/fonctions_principales/convertDistance_Function.js';
import { isEmptyValue } from '../functions/fonctions_annexes/isEmptyValue_Function.js';
$(function () {
$("#convertDistanceForm").submit((event) => {
event.preventDefault();
let firstValue = $('#firstValue').val();
const unitFirstValue = $("#firstValueUnit option:selected").text();
const secondValue = $("#secondValue option:selected").text();
if(isEmptyValue(firstValue) || isEmptyValue(secondValue)) {
$('.results').html(emptyMessageError);
}
else {
firstValue = parseFloat(firstValue.replace(/\s/g,''));
$('.results').html(convertDistance(firstValue, unitFirstValue, secondValue));
}
});
});