Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Scripts not working right

Avatar

Level 4

Hi All,

I am having problem with the following script, and I do not know why it is not working. On printing of this form a message should display. this part works fine. However, if "Yes" is selected from the message box a text called Maskedfld1 should become visible, else if "No" a textfield call SSN should become visible. This is the part that does not work. Here is my code:

On preprint event:

 

xfa.host.messageBox("Are you printing to send hard copy?", "Question?", 3,2)

if(xfa.host.response==3){
  Maskedfld1.presence="visible";
  SSN.presence="invisible";
}
else if(xfa.host.response==2){

  SSN.presence="visible";
  Maskedfld1.presence="invisible";

}

 

I think the xfa.host.response may be the wrong thing to use as the response to the YES, and NO from the messagebox, but I do not know what to use there. I need help with this.

Thanks

v/r

Tammy

4 Replies

Avatar

Level 8

Are you saving the document as a dynamic document?

Avatar

Level 8

var buttonclicked = xfa.host.messageBox("Are you printing to send hard copy?", "Question?", 3,2)

if (buttonclicked == 3) {
......

Avatar

Level 4

Should this reply you provided be placed on the click event? This is because the message part which works should be on the preprint event, and based on if "3" which in this case is "Yes" selection, it should turn the "rectangle, named Maskedfld visible, and if "2" which is "No",  should turn the SSN field visible, and the Maskedfld invisible. Right now the part the script of:

if (buttonclicked == 3) {

  Maskedfld1.presence="visible";

  SSN.presence="invisible";

}

else if(buttonclicked==2){

  SSN.presence="visible";  

   Maskedfld1.presence="invisible";

}

is not working.

Thanks a lot for your response.

v/r

Tammy

Avatar

Level 10

Hi,

one reason why it doesn't work is you use the Yes/No buttons which returns either the value 3 (No clicked) or 4 (Yes clicked).

So you need to change the value you trying to compare.

var question = xfa.host.messageBox("Are you printing to send hard copy?", "Question?", 3,2);

SSN.presence = question == 3 ? "visible" : "invisible";

Maskedfld1.presence = question == 4 ? "visible" : "invisible";