Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var myHtml = '';
$('input[data-name^="ff_repeater_field_name"]').each(function(){
let value = $(this).val();
let position = $(this).attr('data-name').substr( $(this).attr('data-name').length -3, 1);
if (value !== '') {
/*My repeater field only consists of 2 columns, so position 0 = 1st column, 2 = 2nd column*/
if (position == '0') {
myHtml = myHtml + `${escapeHtml(value)}:<br>`;
} else {
myHtml = myHtml + `<i>${escapeHtml(value)}</i><br><br>`;
}
}
});
myHtml = myHtml + '<br>';
$('.your_display_div_class').html(myHtml);
function escapeHtml(text) {
return text
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment