Skip to main content
Nintex Community Menu Bar

Forms: JavaScript Comparison Operator Issues

  • May 19, 2017 8:46 PM UTC
  • 10 replies
  • 12 views
  • Translate All

kelliganp
Forum|alt.badge.img+10

Hi Folks,

In Nintex Forms, I am having an issue with a comparison operator. It seems like is should be pretty straight forward.

I have a button that when clicked, puts the current user's preferred name into a text control (jsvar_518_QMName). This should only happen when a choice control (jsvar_FormNomen) has the text value "518" selected.

When "518" is the selected value and the button is clicked, the first code segment (==) below does not put the current user name in the text control as expected but the second segment (==) does put the current user name in the text control. This seems to tell me that the code works but it is not reading the choice selection. Does anyone know what the issue may be?

if (jsvar_FormNomen == "518") {
     NWF$('#'+ jsvar_518_QMName).val(NWF$('#'+ jsvar_CurUserPreferredName_CAL).val() +" (Current User)");
}

//***********************************************

if (jsvar_FormNomen != "518") {
     NWF$('#'+ jsvar_518_QMName).val(NWF$('#'+ jsvar_CurUserPreferredName_CAL).val() +" (Current User)");
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Thanks and Regards,

Patrick Kelligan

10 replies

Forum|alt.badge.img+7

Hi Patrick Kelligan‌

I think you would need:

if (NWF$('#'+ jsvar_FormNomen).val() == "518") {
     NWF$('#'+ jsvar_518_QMName).val(NWF$('#'+ jsvar_CurUserPreferredName_CAL).val() +" (Current User)");
}

‌ ‌ ‌

Translate

kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • May 22, 2017 3:16 PM UTC

Thanks Paul Crawford‌! That did it.

Translate

kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • May 22, 2017 7:27 PM UTC

Hi Paul,

Advancing this issue, I want to nest some if statements. They will be much more sophisticated than what is shown below but I am getting an error with this simplified example. Can you see what I am doing wrong?

function signForm() {
     if (NWF$('#'+ jsvar_FormNomen).val() == "518") {
          if (NWF$('#'+ jsvar_StateID).val() == 0) {
               var curDate = new Date();
          }
     }
}‍‍‍‍‍‍‍

Thanks,

Patrick

Translate

Forum|alt.badge.img+7

Hi Patrick Kelligan‌

what is the error being thrown? Can you screen shot the error?

Translate

kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • May 22, 2017 7:42 PM UTC

Thanks Paul,

Two errors in the console...

SEC7111: HTTPS security is compromised by http://code.jquery.com/jquery-2.2.4.min.js

SCRIPT5007: Object expected

Bottom line, upon clicking the button, the screen refreshes without working the code.

Translate

Forum|alt.badge.img+7

Hi Patrick Kelligan‌

I cannot see anything wrong with that code and it works fine for me. is there something else that could be causing the issue?

Translate

kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • May 22, 2017 8:12 PM UTC

Not sure Paul.

The nested if is what causes the fail. As soon as I comment out the nested part, there are no issues.

Translate

Forum|alt.badge.img+7

Patrick Kelligan‌

What do you have in the client click settings of the button? I used signForm()?

could it be the jSignature.min.js causing an issue? are you using this?

the first error: SEC7111: HTTPS security is compromised by http://code.jquery.com/jquery-2.2.4.min.js is IE's way of warning about mixed content (HTTP and HTTPS resources on a secure page). Is you change the script link to:

https://code.jquery.com/jquery-2.2.4.min.js 

Should get rid of this error.

the second error is specifically due to the jSignature.min.js

Translate

kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • May 22, 2017 9:26 PM UTC

The issue was that I failed to define "jsvar_StateID" in the "Client ID JavaScript variable name" field of the control in question.

Sorry for the wild goose chase.

Thanks again ‌!!

Translate

Forum|alt.badge.img+7

Haha, the number of times i have done that!!

Glad we got there in the end!!!

Translate