Last active
November 10, 2022 03:20
-
-
Save jennlee20/1a226e18f057e393b3e3c64a93cae918 to your computer and use it in GitHub Desktop.
This file contains 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
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, "&") | |
.replace(/</g, "<") | |
.replace(/>/g, ">") | |
.replace(/"/g, """) | |
.replace(/'/g, "'"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment