diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index 3a681a9..2ae8372 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -1320,12 +1320,30 @@ function _mpApplyExamVisibility(selectedExam) { // (no querySelectorAll — así capturamos section-title y otros sin data-campo-id) var docBody = document.querySelector('.doc-body'); if (!docBody) { console.warn('[tomas] .doc-body no encontrado'); return; } + // Encontrar el contenedor real donde están los campos + var fieldContainer = docBody; var children = Array.from(docBody.children); - console.log('[tomas] docBody.children.length:', children.length, - '| seps en children:', children.filter(function(c){return c.classList.contains('esquema-sep');}).length); + var sepsInChildren = children.filter(function(c){return c.classList.contains('esquema-sep');}).length; + console.log('[tomas] docBody.children.length:', children.length, '| seps en children:', sepsInChildren); + if (sepsInChildren === 0 && children.length > 0) { + // Los campos están anidados — buscar el contenedor que tenga esquema-sep + var found = null; + children.forEach(function(child) { + if (!found && child.querySelector('.esquema-sep')) found = child; + }); + if (found) { + fieldContainer = found; + console.log('[tomas] usando contenedor anidado:', found.tagName, found.className); + } else { + // Intentar con querySelectorAll en todo el doc-body + console.warn('[tomas] no se encontró .esquema-sep en hijos directos, usando querySelectorAll fallback'); + fieldContainer = null; + } + } + var childList = fieldContainer ? Array.from(fieldContainer.children) : []; var inHidden = false; var hiddenCount = 0; - children.forEach(function(child) { + childList.forEach(function(child) { if (child.classList.contains('esquema-sep')) { var cid = child.getAttribute('data-campo-id') || ''; if (allTomaSeps[cid] !== undefined) {