Crow Canyon Software Forum
Hiding a DIV in a print item template
Quote from Jay on January 30, 2023, 2:19 pmI 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: [[Requester||Requester]]<br />
Direct Manager: [[Manager||Direct Manager]]<br />
General Manager: [[GeneralManager||General/Group Manager]]</p>
<div id="requestType">Request Type: [[RequestType||Request Type]]</div><p>Training (If applicable)<br />
Course Name: [[CourseName||Course Name]]<br />
Course Organiser: [[CourseOrganiser||Course Organiser]]<br />
Course Date: [[DateTimeHeld||Date & Time Held]]Course Location: [[Location||Location]]<br />
Early Bid Pricing: <br />
GL Code: [[Training_x0020_GL_x0020_code||Training GL code]]</p>
<p> </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
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: [[Requester||Requester]]<br />
Direct Manager: [[Manager||Direct Manager]]<br />
General Manager: [[GeneralManager||General/Group Manager]]</p>
<div id="requestType">Request Type: [[RequestType||Request Type]]</div><p>Training (If applicable)<br />
Course Name: [[CourseName||Course Name]]<br />
Course Organiser: [[CourseOrganiser||Course Organiser]]<br />
Course Date: [[DateTimeHeld||Date & Time Held]]Course Location: [[Location||Location]]<br />
Early Bid Pricing: <br />
GL Code: [[Training_x0020_GL_x0020_code||Training GL code]]</p>
<p> </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
Quote from Jay on January 31, 2023, 4:04 pmMy 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!
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!