Answer the question
In order to leave comments, you need to log in
Which book or video course on linux to choose?
Recommend some good and up-to-date book or video course on linux....
Answer the question
In order to leave comments, you need to log in
more or less decent js is written like this
const servPrice = {
lin: 0,
clean: 0,
};
/**
* @param {HTMLInputElement[]} elements
* @param {HTMLInputElement} valueElement
* @param {{lin: number; clean: number}} servPrice
* @param {'lin'|'clean'} propName
* @param {Function} done
*/
function act(elements, valueElement, servPrice, propName, done) {
if (elements.length === 0) {
return;
}
elements.forEach((element) => {
element.addEventListener('change', () => {
switch (element.value) {
case 'Yes':
servPrice[propName] = parseInt(valueElement.getAttribute("data-price"), 10);
break;
case 'No':
servPrice[propName] = 0;
break;
default:
}
done();
});
});
}
act(
[...document.querySelectorAll('input[name="Linen_Service"]')],
document.querySelector('input[name="linen_price"]'),
servPrice,
'lin',
renewDatas,
);
act(
[...document.querySelectorAll('input[name="Cleaning_Service"]')],
document.querySelector('input[name="cleaning_price"]'),
servPrice,
'clean',
renewDatas,
);
well if so
let linServPrice = getValue("Linen_Service","linen_price"),
let cleanServPrice =getValue("Cleaning_Service","cleaning_price");
function getValue(Service,price){
if (document.querySelector(`input[name=${Service}]`)){
...
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question