Remove certain values from pricing category PAX selector

// Edit this object with the id of the select element and a array of values to // keep. var optionsToKeep = { 'activity-pcat6289': [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], }; var filterSelectBoxes = function(options) { var toDelete = []; [].forEach.call(Object.keys(options), function(key) { // Fetch the element from the DOM tree var containers = document.querySelectorAll('.row-fluid'); [].forEach.call(containers, function(container) { var select = container.querySelector('#' + key); // Add the elements to a array that don't fit the conditions [].forEach.call(select.children, function(child) { if (options[key].indexOf(Number(child.value)) === -1) { toDelete.push(child); } }); }); }); // Delete all the elements in the array from the DOM tree [].forEach.call(toDelete, function(option) { option.remove(); }); }; // When the page is done loading all of the content document.addEventListener('DOMContentLoaded', function() { // Filter the select boxes according to the above options filterSelectBoxes(optionsToKeep); // create an observer instance var observer = new MutationObserver(function(mutations) { filterSelectBoxes(optionsToKeep); }); // configuration of the observer: var config = { subtree: true, childList: true }; // pass in the target node, as well as the observer options observer.observe(document.querySelector('.row-fluid'), config); });

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.