Hello,
Trying to figure out the form name, but not getting desired result with the following:
if (xfa.form.name == "form050") then
Solved! Go to Solution.
Views
Replies
Total Likes
Your code fails because of "then", which isn't javascript.
I.e. the line fails silently, which I find quite odd. If not an exception, the js engine should at least generate a syntax error. What happens is that it simply continues execution.
This produces the same behaviour:
if (false) askldalksdjhaldh
{ app.alert("you should never see this message."); }
This produces an error (as it should):
if (false) askldalksdjhaldh { app.alert("you should never see this message."); }
Views
Replies
Total Likes
One way is to add the name of the form as the title in the form properties. You can then reference "xfa.host.title".
Steve
Views
Replies
Total Likes
Thanks for the suggestion, but my if statement still fails to execute properly after I changed my form properties to:
and changed my code to:
if (xfa.host.title == "MC-050") then
{
xfa.host.messageBox("In == mc050, UPPERcase p section ALNvali.","Error"); // vh
What happens is that the comparison I make (above), even though the title does NOT equal MC-050, determines the title to be equal and I get my message to pop up. Just to test, I added the following to verify the title:
xfa.host.messageBox(xfa.host.title,"Error"); // vh
Views
Replies
Total Likes
Are you using FormCalc or JavaScript?
Views
Replies
Total Likes
Javascript
Views
Replies
Total Likes
This works for me....
// form1.page1.btn::click - (JavaScript, client)
if (xfa.host.title == "HowTheHeck.pdf") {
xfa.host.messageBox(xfa.host.title);
}
else {
xfa.host.messageBox("Not HowTheHeck.pdf");
}
Steve
What if you switch your comparison value after the == to say, "Form.pdf" or some value not equal to what your form title is? I ran into this because initially my test was just like yours where I had the "nice" or expected comparison that should work, but then I found out that my 'else' portion was never being accessed because the first equality comparison was somehow ALWAYS true. Thanks.
Views
Replies
Total Likes
Your code fails because of "then", which isn't javascript.
I.e. the line fails silently, which I find quite odd. If not an exception, the js engine should at least generate a syntax error. What happens is that it simply continues execution.
This produces the same behaviour:
if (false) askldalksdjhaldh
{ app.alert("you should never see this message."); }
This produces an error (as it should):
if (false) askldalksdjhaldh { app.alert("you should never see this message."); }
Views
Replies
Total Likes
Oh no! That means I got a lot of code to go through and fix....not good! >:-<
I really wish they'd address this -- I can't imagine being the only one that's ran into this "silent fail" issue with SmartForms and JavaScript.
I'll change my code and see if it all works now.
Thanks for the tip!!!
Views
Replies
Total Likes
Views
Likes
Replies