Expand my Community achievements bar.

xfa.host.response cancel button

Avatar

Former Community Member

Hello,

I'm using the response dialog box and i have to know if the user has pressed cancel or ok.

For the moment i can't see how to do that when the response is empty.

I've seen in documentation that null is  returned if cancel button is pressed but for me it's always en empty string.

Here is my script :

var response  = xfa.host.response("reponse dialog box","",);

var nullCheck = (response == null);

var emptyCheck = (response == "");

xfa.host.messageBox( "nullCheck is " + nullCheck);

xfa.host.messageBox( "emptyCheck is " + emptyCheck);

//xfa.host.messageBox( "response is " + response);

xfa.host.messageBox(response);

Somebody somewhere has an explanation ?

Philippe Vandenhove

7 Replies

Avatar

Former Community Member

The problem is in the 1st line .....there is no xfa.host.response function .....it is a function of the app object in Acrobat so the co

mmand would be:

app.response("This is the message I want to show");

If you are using Acrobat you can see any Javascript runtime errors by clicking Ctrl+j  and bring up the Javascript console. This will indicate if there are issues in your script.

Paul

Avatar

Former Community Member

Here is the documentation of the function:

http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/wwhelp/wwhimpl/common/html/wwhelp.htm?conte...

I use adobe reader and i see no error message.

The dialogs box are displayed correctly.

My problem is that i don't know if the user has clicked OK or CANCEL if the value entered is a an empty string.

Regards

Avatar

Former Community Member

If they hit Cancel then you get a null back .....if they hit OK but do not fill out the input then you get an empty string "".

Paul

Avatar

Former Community Member

Perhaps my check (response == null) is wrong but it seems that i don't received a null value.

Variable nullCheck is always set to false.

var response  = xfa.host.response("reponse dialog box","");

var nullCheck = (response == null);

var emptyCheck = (response == "");

xfa.host.messageBox( "nullCheck is " + nullCheck);

xfa.host.messageBox( "emptyCheck is " + emptyCheck);

//xfa.host.messageBox( "response is " + response);

Regards,

Avatar

Former Community Member

Works fine for me ...i changed the name of the variable from response to response1 beacuse I was concerned that response might be a reserved word.

Paul

Avatar

Former Community Member

For me the null check is always false. I use Adobe Reader 9.3.0 and Adobe LiveCycle Designer ES 8.2.1.3158

Avatar

Level 7

From the for what's its worth department:

When using == to test for null, "" and 0 will return (true)

When using === to test for null "" and 0 will return (false)

Stephen