Dynamic form confirmation page

Hi all,

I’m looking to hide empty questions and responses on the confirmation page.

Currently I’m using:

%begin_response_10966_q6%

    <p>%question_name_10966_q6%</p>
    <p>%response_10966_q6%</p>

%end_response_10966_q6%

to hide the question and answer if its empty.

The problem I’m facing is hiding the section title if ALL the questions and responses of that section are empty. If I don’t do this and all the responses are empty the user will just see a title on its own.

Any help is appreciated.

Thanks.

Probably best to use JavaScript for this (either SSJS or just regular client side JS).

If you drop all the responses into an array and check if anything has a value, you could get away with something along the lines of:

<script runat="server">
var responses = ['%response_368_q1%','%response_368_q2%','%response_368_q3%','%response_368_q4%','%response_368_q5%'];

if (!responses.reduce((acc, val) => !!val || acc, false)) {
    print ("<h1> You didn't fill in any fields!");
}
</script>

(assuming you’re on >=5.4)

The JS-less alternatives are fairly obtuse. You can’t do any OR logic with the responses, and the ^empty keyword modifier doesn’t appear to behave as I’d expect when used in a conditional keyword (on 5.5). You’d probably be left with something like:

<!--

%begin_response_368_q1%
<!-- -->
%end_response_368_q1%
%begin_response_368_q2%
<!-- -->
%end_response_368_q2%
%begin_response_368_q3%
<!-- -->
%end_response_368_q3%
%begin_response_368_q4%
<!-- -->
%end_response_368_q4%
%begin_response_368_q5%
<!-- -->
%end_response_368_q5%

<div style="display:none;">

<!-- -->

<h1>You didn't fill in any fields!</h1>

<!--

%begin_response_368_q1%
<!-- -->
%end_response_368_q1%
%begin_response_368_q2%
<!-- -->
%end_response_368_q2%
%begin_response_368_q3%
<!-- -->
%end_response_368_q3%
%begin_response_368_q4%
<!-- -->
%end_response_368_q4%
%begin_response_368_q5%
<!-- -->
%end_response_368_q5%

</div>

<!-- -->

but don’t do that.

I’ve used this with success:

On confirmation page - %form_summary%

As it gets printed in a table format, just the following js:

<script type="text/javascript">
$("tr").not(":has(td:nth-child(2):not(:empty))").hide();
</script>