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

17 lines
714 B
JavaScript

import { convertDistance } from '../functions/fonctions_principales/convertDistance_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));
}
});
});