Conditional Diplay

Forminator Forms
20 January, 2025 19:00:10
recuniforms
Topics: 8
Messages: 47
I have two tables in my PDF and, for each, I would like to display a column (<td class="travel" for both) only if {select-10} is "Travel Set". Google searches provide script solutions, but I'm not sure I can apply those ... ? Thanks in advance!
20 January, 2025 23:48:55
E2Pdf
Support
Topics: 7
Messages: 3413
Hello,

You should use the [e2pdf-if] shortcode: https://codefile.io/f/eowEIQ7HQa

IMPORTANT: Make sure to enable the "Disable WYSIWYG Editor" option in the HTML field to prevent any reformatting issues.
We would really appreciate your feedback at WordPress.org!
21 January, 2025 05:24:16
recuniforms
Topics: 8
Messages: 47
Thank you! It worked perfectly for the first index (page 1), but it's still displaying <td class="travel"> for the second index (page 2).

Also, is this something I have to add to each <td> or can I add it once and have it apply to all of class="travel".
21 January, 2025 05:52:55
E2Pdf
Support
Topics: 7
Messages: 3413
It should work on the second page the same way as it does on the first.

Could you please attach some screenshots showing how the values are set on the first and second pages?

If you need class="travel" to be added to separate pages or elements, then yes, it should be added to each required "td".
We would really appreciate your feedback at WordPress.org!
21 January, 2025 15:39:26
recuniforms
Topics: 8
Messages: 47
Page 2 is generated by a foreach loop ...

{foreach:group-3}
<div style="page-break-before: always;">

... so the code is the same. The if statement works well when the index is 1. It is not working when the index is 2.

Re: the class, I have it added to the td. But I'm wondering if I have to add the if statement to each td or if I can apply the if statement to entire class at once.
21 January, 2025 16:46:07
recuniforms
Topics: 8
Messages: 47
I may have discovered the problem.
21 January, 2025 16:55:13
recuniforms
Topics: 8
Messages: 47
I believe the problem is that it isn't handling the nested if statement. Here is what I'm trying to do:

[e2pdf-if] [e2pdf-if-condition]{select-10}[==]Travel Set[/e2pdf-if-condition][e2pdf-if-do]<td width="50" class="travel">[e2pdf-if][e2pdf-if-condition]{select-8}[in_array]a:31:{i:0;s:4:"6001";i:1;s:4:"6006";i:2;s:4:"6007";i:3;s:4:"6010";i:4;s:4:"6011";i:5;s:4:"6012";i:6;s:4:"L025";i:7;s:4:"L036";i:8;s:4:"L040";i:9;s:4:"L043";i:10;s:4:"L044";i:11;s:4:"L045";i:12;s:4:"L049";i:13;s:4:"L051";i:14;s:4:"L052";i:15;s:4:"L056";i:16;s:4:"L059";i:17;s:4:"L060";i:18;s:4:"L062";i:19;s:4:"L066";i:20;s:4:"L067";i:21;s:5:"L1023";i:22;s:5:"L1024";i:23;s:4:"Z108";i:24;s:4:"Z109";i:25;s:4:"Z110";i:26;s:4:"Z111";i:27;s:4:"Z112";i:28;s:4:"Z114";i:29;s:4:"Z115";i:30;s:4:"Z116";}[/e2pdf-if-condition][e2pdf-if-do][e2pdf-format-output search="Youth XS|||Youth S|||Youth M|||Youth L|||Youth XL|||Adult S|||Adult M|||Adult L|||Adult XL|||Adult 2XL" replace="4XS|||3XS|||2XS|||XS|||S|||L|||2XL|||3XL|||4XL|||5XL"]{select-11}[/e2pdf-format-output][/e2pdf-if-do][e2pdf-if-else][e2pdf-format-output search="Youth XS|||Youth S|||Youth M|||Youth L|||Youth XL|||Adult S|||Adult M|||Adult L|||Adult XL|||Adult 2XL" replace="ERROR|||5XS|||4XS|||3XS|||2XS|||S|||L|||XL|||2XL|||ERROR"]{select-11}[/e2pdf-format-output][/e2pdf-if-else][/e2pdf-if]</td>[/e2pdf-if-do]
[/e2pdf-if]

It's outputting code in the PDF.
21 January, 2025 23:08:00
E2Pdf
Support
Topics: 7
Messages: 3413
Unfortunately, yes, nested [e2pdf-if] shortcodes aren't supported, so the shortcode needs to be rebuilt.

Could you please clarify the behavior? Do you need to display:
1. The entire block only when {select-10} is set to "Travel Set" and {select-8} is part of an array?

Or

2. Should it just be a "td" element with a class "travel" when {select-10} is set to "Travel Set," while {select-8} is always displayed but in "td" without class "travel"?
We would really appreciate your feedback at WordPress.org!
22 January, 2025 06:31:57
recuniforms
Topics: 8
Messages: 47
If I'm understanding correctly, it's neither.

I need anything with class = "travel" to display when {select-10} is "Travel Set." I need it to be hidden when any other option is selected. The code above accomplished that, but it stopped the nested if statement from working properly.

The nested if statement is a conversion based on user input: if the user selects a certain series of jerseys, it uses a certain 1-to-1 conversion; if it's another series of uniforms, it uses a different 1-to-1 conversion.

So for example:
- if the user selects Alpine Kit for {select-8}, Youth S becomes 3XS
- if the user select Abstract Kit {select 6}, Youth S becomes 5XS

So the three columns of the output here becomes:

SKU 1 / SKU 2 / Size
3XS / 5XS / Youth S

There is also a second table that displays an image of the second jersey where the second column is class = "travel." I don't want that column to display either.

The support desk helped me with this code previously.

But if the user did not select "Travel Set", I do not want the SKU 2 column to be displayed.

I hope I'm explaining it well!
22 January, 2025 08:08:49
E2Pdf
Support
Topics: 7
Messages: 3413
The [e2pdf-if] shortcode supports multiple conditions using [&&]: https://e2pdf.com/docs/shortcodes/logic/e2pdf-if#delimiters. Based on your description, it seems you should be able to move the "td" element into the [e2pdf-if-do] shortcode and apply multiple conditions:

For example: https://codefile.io/f/xkdwczxJZj

This will output the "td" element with the "travel" class and replaced values only if {select-10} equals "Travel Set" and {select-8} is in the array.

We would really appreciate your feedback at WordPress.org!
22 January, 2025 14:49:06
recuniforms
Topics: 8
Messages: 47
Thank you!

I think that should work if I modify it slightly. If I'm understanding correctly, as is, the td will display when:

- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-8} is not in the array (if else)

The trouble that the td still displays when {select-10} =/= "Travel Set", but {select-8} is not in the array.

I need td to display when:

- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-10} = "Travel Set" AND {select-8} is in the array (a second &&)

I don't want the td to display when {select-10} =/= "Travel Set" regardless of whether {select-8} is in the array.

I tried briefly, but didn't get it to work (though it doesn't seem terribly complicated). I should be able to have multiple if statements (not nested) before the else, correct?
22 January, 2025 14:49:07
recuniforms
Topics: 8
Messages: 47
Thank you!

I think that should work if I modify it slightly. If I'm understanding correctly, as is, the td will display when:

- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-8} is not in the array (if else)

The trouble that the td still displays when {select-10} =/= "Travel Set", but {select-8} is not in the array.

I need td to display when:

- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-10} = "Travel Set" AND {select-8} is in the array (a second &&)

I don't want the td to display when {select-10} =/= "Travel Set" regardless of whether {select-8} is in the array.

I tried briefly, but didn't get it to work (though it doesn't seem terribly complicated). I should be able to have multiple if statements (not nested) before the else, correct?
22 January, 2025 17:29:53
recuniforms
Topics: 8
Messages: 47
Here's the code I'm trying:

<td width="50">[e2pdf-if][e2pdf-if-condition] {select-10}[==]Travel Set[&&] {select-8}[in_array]a:31:{i:0;s:4:"6001";i:1;s:4:"6006";i:2;s:4:"6007";i:3;s:4:"6010";i:4;s:4:"6011";i:5;s:4:"6012";i:6;s:4:"L025";i:7;s:4:"L036";i:8;s:4:"L040";i:9;s:4:"L043";i:10;s:4:"L044";i:11;s:4:"L045";i:12;s:4:"L049";i:13;s:4:"L051";i:14;s:4:"L052";i:15;s:4:"L056";i:16;s:4:"L059";i:17;s:4:"L060";i:18;s:4:"L062";i:19;s:4:"L066";i:20;s:4:"L067";i:21;s:5:"L1023";i:22;s:5:"L1024";i:23;s:4:"Z108";i:24;s:4:"Z109";i:25;s:4:"Z110";i:26;s:4:"Z111";i:27;s:4:"Z112";i:28;s:4:"Z114";i:29;s:4:"Z115";i:30;s:4:"Z116";}[/e2pdf-if-condition]

[e2pdf-if-do][e2pdf-format-output search="Youth XS|||Youth S|||Youth M|||Youth L|||Youth XL|||Adult S|||Adult M|||Adult L|||Adult XL|||Adult 2XL" replace="4XS|||3XS|||2XS|||XS|||S|||L|||2XL|||3XL|||4XL|||5XL"]{select-11}[/e2pdf-format-output][/e2pdf-if-do]

[e2pdf-if-condition]{select-10}[==]Travel Set[&&]{select-8}[not_in_array]a:31:{i:0;s:4:"6001";i:1;s:4:"6006";i:2;s:4:"6007";i:3;s:4:"6010";i:4;s:4:"6011";i:5;s:4:"6012";i:6;s:4:"L025";i:7;s:4:"L036";i:8;s:4:"L040";i:9;s:4:"L043";i:10;s:4:"L044";i:11;s:4:"L045";i:12;s:4:"L049";i:13;s:4:"L051";i:14;s:4:"L052";i:15;s:4:"L056";i:16;s:4:"L059";i:17;s:4:"L060";i:18;s:4:"L062";i:19;s:4:"L066";i:20;s:4:"L067";i:21;s:5:"L1023";i:22;s:5:"L1024";i:23;s:4:"Z108";i:24;s:4:"Z109";i:25;s:4:"Z110";i:26;s:4:"Z111";i:27;s:4:"Z112";i:28;s:4:"Z114";i:29;s:4:"Z115";i:30;s:4:"Z116";}[/e2pdf-if-condition]

[e2pdf-if-do][e2pdf-format-output search="Youth XS|||Youth S|||Youth M|||Youth L|||Youth XL|||Adult S|||Adult M|||Adult L|||Adult XL|||Adult 2XL" replace="ERROR|||5XS|||4XS|||3XS|||2XS|||S|||L|||XL|||2XL|||ERROR"]{select-11}[/e2pdf-format-output][/e2pdf-if-do][/e2pdf-if]</td>

It's displaying a blank cell, which would seem to mean it's interpreting neither if statements to be true.
22 January, 2025 23:12:02
E2Pdf
Support
Topics: 7
Messages: 3413
Could you please try using the code below to replace the code from the previous message: https://codefile.io/f/BV2LivdPkN

It should replace values if {select-10} is Travel Set, regardless of whether the values are in the array or not.
We would really appreciate your feedback at WordPress.org!
23 January, 2025 05:14:32
recuniforms
Topics: 8
Messages: 47
That worked! Thank you!
23 January, 2025 17:58:21
recuniforms
Topics: 8
Messages: 47
I spoke a little too soon!

It works great when {select-10} = Travel Set, but when {Select-10} =/= Travel Set, it's still showing the cell (though blank). I'd like the cell to be hidden when {Select-10} =/= Travel Set (which should should be the [e2pdf-if-else] condition).

See the attached example.

Here is the code (which is the same you sent previously):

<td width="50">[e2pdf-if][e2pdf-if-condition]{select-10}[==]Travel Set[&&]{select-8}[in_array]a:31:{i:0;s:4:"6001";i:1;s:4:"6006";i:2;s:4:"6007";i:3;s:4:"6010";i:4;s:4:"6011";i:5;s:4:"6012";i:6;s:4:"L025";i:7;s:4:"L036";i:8;s:4:"L040";i:9;s:4:"L043";i:10;s:4:"L044";i:11;s:4:"L045";i:12;s:4:"L049";i:13;s:4:"L051";i:14;s:4:"L052";i:15;s:4:"L056";i:16;s:4:"L059";i:17;s:4:"L060";i:18;s:4:"L062";i:19;s:4:"L066";i:20;s:4:"L067";i:21;s:5:"L1023";i:22;s:5:"L1024";i:23;s:4:"Z108";i:24;s:4:"Z109";i:25;s:4:"Z110";i:26;s:4:"Z111";i:27;s:4:"Z112";i:28;s:4:"Z114";i:29;s:4:"Z115";i:30;s:4:"Z116";}[/e2pdf-if-condition][e2pdf-if-do][e2pdf-format-output search="Youth XS|||Youth S|||Youth M|||Youth L|||Youth XL|||Adult S|||Adult M|||Adult L|||Adult XL|||Adult 2XL" replace="4XS|||3XS|||2XS|||XS|||S|||L|||2XL|||3XL|||4XL|||5XL"]{select-11}[/e2pdf-format-output][/e2pdf-if-do][/e2pdf-if][e2pdf-if][e2pdf-if-condition]{select-10}[==]Travel Set[&&]{select-8}[not_in_array]a:31:{i:0;s:4:"6001";i:1;s:4:"6006";i:2;s:4:"6007";i:3;s:4:"6010";i:4;s:4:"6011";i:5;s:4:"6012";i:6;s:4:"L025";i:7;s:4:"L036";i:8;s:4:"L040";i:9;s:4:"L043";i:10;s:4:"L044";i:11;s:4:"L045";i:12;s:4:"L049";i:13;s:4:"L051";i:14;s:4:"L052";i:15;s:4:"L056";i:16;s:4:"L059";i:17;s:4:"L060";i:18;s:4:"L062";i:19;s:4:"L066";i:20;s:4:"L067";i:21;s:5:"L1023";i:22;s:5:"L1024";i:23;s:4:"Z108";i:24;s:4:"Z109";i:25;s:4:"Z110";i:26;s:4:"Z111";i:27;s:4:"Z112";i:28;s:4:"Z114";i:29;s:4:"Z115";i:30;s:4:"Z116";}[/e2pdf-if-condition][e2pdf-if-do][e2pdf-format-output search="Youth XS|||Youth S|||Youth M|||Youth L|||Youth XL|||Adult S|||Adult M|||Adult L|||Adult XL|||Adult 2XL" replace="ERROR|||5XS|||4XS|||3XS|||2XS|||S|||L|||XL|||2XL|||ERROR"]{select-11}[/e2pdf-format-output][/e2pdf-if-do][/e2pdf-if]</td>

Thank you in advance!
23 January, 2025 18:00:16
recuniforms
Topics: 8
Messages: 47
The cell in top row is being hidden properly (it would say Size SKU 2) -- hence why there is one less column in the top row -- but rows 2-6 are displaying blank cells.
23 January, 2025 22:56:07
E2Pdf
Support
Topics: 7
Messages: 3413
Your "td" element is currently outside the "[e2pdf-if]" condition, so it is always being displayed. If you want it to appear only when {select-10} is set to "Travel Set" you need to move it inside the "[e2pdf-if-do]" shortcode of "[e2pdf-if]" conditions: https://codefile.io/f/aVuG2FgwfW.

If this doesn't resolve the issue, please copy all the HTML code you're using and upload it to https://codefile.io.
We would really appreciate your feedback at WordPress.org!
24 January, 2025 04:57:35
recuniforms
Topics: 8
Messages: 47
That makes sense! Thank you!