I am using pods custom fields ( multi select ) for the dynamic data. -
How can I can display the output as separate boxes (like buttons) instead of the usual comma separated value?
problem is those texts are saved as text strings. they don’t have any tag with them
if they came with tags like maybe;
<b>text</b>,
<b>text</b>,
<b>text</b>
something like this it would be possible to select them with CSS give padding background whatever would be very easy. one way to solve this is save the strings like that with simple HTML tags.
or manipulate and re-render with js. here this find the .custom-field-text class checks if there is texts with commas inside it and add htm ltags to it. and than you can write simple custom CSS.
document.addEventListener('DOMContentLoaded', function () {
// Select the element with the class .custom-field-text
var element = document.querySelector('.custom-field-text');
// Check if the element exists to avoid errors
if (element) {
// Split the text content by commas
var texts = element.textContent.split(',');
// Wrap each text piece with <b> tags and join them back into a string
var boldTexts = texts.map(text => `<b>${text}</b>`).join('');
// Update the HTML content of the original element
element.innerHTML = boldTexts;
}
});
This is a “solution” I ended up doing the exact thing. Using .split and then turning those into their own tags. But I wish there was a better solution, especially for any of the non coders out there.