Expand my Community achievements bar.

SOLVED

Controlling whether a checkbox gets printed

Avatar

Level 3

Hi guys

I'm attempting to control whether or not a checkbox object is displayed when printed, based on whether or not the box is checked.

I only want the checkbox object to be printed if the checkbox is checked. It should be visible to the user regardless.

I have created a simple script that I believe should do the job, but the checkbox object prints regardless of its state.

form1.#subform[0].CheckBox1::change - (JavaScript, client)
if (this.rawValue == 1) {

  this.relevant = "+print";
}
else {

  this.relevant = "-print";
}

It can be noted that I am adjustng the 'relevant' attribute, in response to the 'change' event.

Any ideas on where I have gone wrong??

Thanks

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Ok I just tried it and your code is fine. You have to save the form as dynamic for those changes to take effect. Do a File/SaveAs and choose dynamic PDF and try it again.

Paul

View solution in original post

7 Replies

Avatar

Level 4

The relevant="+print" doesn't work for me, but if i leave the string empty it works fine.

I've attached an example.

Avatar

Level 3

your example works, yet when I use the exact same code on checkboxes in my own form, they either never print or always print.

can the presence of other fields on the page alter the .relevant attribute? should we be assigning the script to the prePrint event,

since that's the only time that it is truly relevant?

If it can be attached to the prePrint event, I think that would save me some work as I will be having many checkboxes,

and I could just go with a for loop that cycles through each and checks the rawValue of each.

Would that work?

Thanks

Avatar

Level 4

It might.

If it doesn't, post your form so i can have a look at it.

Avatar

Level 3

Here is the form that I am tinkering with. The relevant field is the checkbox with the caption "Print?"

Any thoughts?

Thanks

Avatar

Level 4

Your PDF is still queued.... try to post it again.

Avatar

Level 3

Again the objects are near the top of the form

Avatar

Correct answer by
Former Community Member

Ok I just tried it and your code is fine. You have to save the form as dynamic for those changes to take effect. Do a File/SaveAs and choose dynamic PDF and try it again.

Paul

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----