Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jennlee20/1a226e18f057e393b3e3c64a93cae918 to your computer and use it in GitHub Desktop.
Save jennlee20/1a226e18f057e393b3e3c64a93cae918 to your computer and use it in GitHub Desktop.
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