Give this script a try. Just change the form ID (401), list field ID (1), and results field ID (2) at the bottom of the code:
<script>
jQuery(function($){
function listFieldRowCount(formId, fieldId, totalFieldId) {
const listFieldSel = '#field_' + formId + '_' + fieldId;
const totalFieldSel = '#input_' + formId + '_' + totalFieldId;
const $list = $(listFieldSel);
const $total = $(totalFieldSel);
if (!$list.length || !$total.length) return;
// Next paint (lets GF update DOM first)
requestAnimationFrame(function(){
const totalRows = $list.find('.gfield_list_group').length;
// console.log('[GF] rows:', totalRows);
if ($total.val() != totalRows) {
$total.val(totalRows).trigger('change');
}
});
}
function listFieldRowTotal(formId, fieldId, totalFieldId) {
const listFieldSel = '#field_' + formId + '_' + fieldId;
const $list = $(listFieldSel);
if (!$list.length) return;
// Prevent double-init on redraws
if ($list.data('rowTotalInited')) return;
$list.data('rowTotalInited', true);
// Initial count
listFieldRowCount(formId, fieldId, totalFieldId);
// Add/Delete row events
$(document).on('gform_list_item_add gform_list_item_delete', function(event, fId, fldId){
if (parseInt(fId,10) === parseInt(formId,10) && parseInt(fldId,10) === parseInt(fieldId,10)) {
listFieldRowCount(formId, fieldId, totalFieldId);
}
});
// Fallback: observe only the list container body for child changes
const container = $list.find('.gfield_list_container, table.gfield_list')[0] || $list[0];
let obsTimer = null;
if (container && 'MutationObserver' in window) {
const mo = new MutationObserver(function(){
// debounce to one update per tick
if (obsTimer) return;
obsTimer = requestAnimationFrame(function(){
obsTimer = null;
listFieldRowCount(formId, fieldId, totalFieldId);
});
});
mo.observe(container, { childList: true, subtree: true });
$list.data('rowTotalObserver', mo);
}
}
// Init on first load
listFieldRowTotal(401, 1, 2);
// Re-init on GF redraws (AJAX/conditional/page change)
$(document).on('gform/post_render', function(e, formId){
if (parseInt(formId,10) === 401) {
listFieldRowTotal(401, 1, 2);
}
});
});
</script>
Disclaimer: Third-party plugins or code snippets that are provided or referenced by our Support Team or documentation, are provided as suggestions only. We do not evaluate, test, guarantee or officially support third-party solutions or code-snippets. You are wholly responsible for determining if any suggestion or code snippet provided is sufficient to meet the functional, security, legal, ongoing cost and support needs of your project, as well as testing and confirming performance across future product updates.