Crow Canyon Software Forum

Forum Navigation
Please or Register to create posts and topics.

Hiding a DIV in a print item template

I previously posted this as part of a different thread but worry this new attempt to solve my issue may have got buried.
I am trying to toggle DIV visibility so that a section does not appear in the final PDF when it is not applicable
.......

I have put a DIV around one of the form fields to make it less complicated than querying an array of checkboxes.

This is the HTML with the important bits in bold
<p>Requester:&nbsp;[[Requester||Requester]]<br />
Direct Manager:&nbsp;[[Manager||Direct Manager]]<br />
General Manager:&nbsp;[[GeneralManager||General/Group Manager]]</p>
<div id="requestType">Request Type: [[RequestType||Request Type]]</div><p>Training (If applicable)<br />
Course Name:&nbsp;[[CourseName||Course Name]]<br />
Course Organiser:&nbsp;[[CourseOrganiser||Course Organiser]]<br />
Course Date:&nbsp;[[DateTimeHeld||Date &amp; Time Held]]Course Location:&nbsp;[[Location||Location]]<br />
Early Bid Pricing:&nbsp;<br />
GL Code:&nbsp;[[Training_x0020_GL_x0020_code||Training GL code]]</p>
<p>&nbsp;</p>
<div id="travelDiv" style="display:none;">blah blah blah blah</div>

And this is the Javascript

// add your script to change printed Text.

let ele = document.getElementById('requestType');

// check if DIV contains the word "Training".
if (ele.innerHTML.includes('Training')) {
$('#travelDiv').toggle();
}

When I see the output (both in the edit item template window and the resulting PDF file the travelDiv DIV is always hidden.
requestType text = Training so it should toggle the DIV visibility

My bad... would have worked perfectly (and does now) had I not copy and pasted my JS in several places and forgotten to fix a typo!