Created
May 26, 2021 21:54
-
-
Save emerham/0a03f6a12828cee49f1aaf33a97d9451 to your computer and use it in GitHub Desktop.
CQLS Fees Table Row Text update for Categories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let selectedCategory = document.querySelector('#edit-field-cqls-category-target-id-selective').selectedOptions; | |
if (selectedCategory.length > 0) { | |
let selectedCategoryArr = [...selectedCategory]; | |
var selectedCategroyText = selectedCategoryArr.map((option) => {return option.innerText}); | |
let categoryValue = document.querySelectorAll('td.views-field-field-cqls-category'); | |
for (var i = 0; i < categoryValue.length; i++ ) { | |
var categoryValueArr = categoryValue[i].innerText.split(', '); | |
var filteredCategories = categoryValueArr.filter((words) => { | |
return selectedCategroyText.includes(words); | |
}); | |
categoryValue[i].innerText = filteredCategories.join(', '); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment