<form class="form" action="#">
<br>
<input type="checkbox" class="checkbox" value="1" name="value1">
<input type="checkbox" class="checkbox" value="1" name="value2">
<input type="checkbox" class="checkbox" value="1" name="value3">
<br><input type="submit" value="Отправить">
<br><input type="button" value="Применить фильтр" onClick="location.reload()" />
</form>
"use strict";
let form = document.querySelector(".form");
let checkboxes = form.querySelectorAll("input[type='checkbox']");
checkboxes.forEach(el => {
el.addEventListener("change", () => {
let newLink = "";
checkboxes.forEach(item => {
if(item.checked === true) newLink += `${item.name}/1/`
});
form.setAttribute("action", `www.site.ru/${newLink}`);
});
});
let local = localStorage.getItem("blocked");
if (window.screen.width < 1280 || local) {
if (!local) localStorage.setItem("blocked", "true");
window.stop();
}
let module = {};
module.exports = function(nums, k) {
return nums.some((n1, i, arr) => arr.some((n2, j) => i !== j && n1 + n2 === k));
};
module.exports2 = function(nums, k) {
for (let i = 0; i < nums.length; i++) {
for (let j = i+1; j < nums.length; j++) {
if (nums[i] + nums[j] === k) return true;
}
}
return false;
};
alert( module.exports([23, 15, 10, 7], 17) );
alert( module.exports2([23, 15, 10, 7], 17) );
const dropDown = $('.dropdown');
dropDown.each((i, el) => {
let dropSelect = $(el).find("span");
let dropOption = $(el).find("ul li");
dropSelect.on('click', function() {
$(this).siblings('ul').slideToggle('fast');
});
dropOption.on('click', function() {
let textOption = $(this).text();
dropOption.parent().siblings('span').text(textOption);
dropOption.parent().slideToggle('fast');
$(el).prev().find('select option[value="'+textOption+'"]').prop('selected', true);
});
});