Textbox value undefined in Javascript

  • 13 April 2017
  • 8 replies
  • 6 views

Badge +1

I have a textbox with Client ID JavaScript variable name set to 'UserMnemonicId'

On form load i call javasrcipt function and display alert .

NWF$(document).ready(function(){
alert('test function');
alert(NWF$('#UserMnemonicId').val());
});

I get both the alerts but for the second alert it displays 'undefined'

Don't know why the textbox value is displayed as 'undefned'

Is there anything that i am doing wrong or missing?


8 replies

Userlevel 5
Badge +14

you've used wrong syntax, try following

alert(NWF$('#' + UserMnemonicId).val());

Userlevel 5
Badge +14

Converted  discussion to question

Badge +1

Thanks Marian, it worked

Badge +3

What Am I Missing? 

I get an alert w/ 'abc1' and then an alert w/ 'undefined' and then 'abc2'. 

Am I missing a directive or setting in Nintex get this to work?

function showPassword(){

var displayWindowsUserName = 'abc1';

alert(displayWindowsUserName );

displayWindowsUserName = NWF$('#' + jsWindowsUserName);

alert(displayWindowsUserName.val());

alert('abc2');

}

219526_pastedImage_1.png

Thank You!

Badge +11

I think the  NWF$ is not defined?
I am new to JS myself ....

NWF$(document).ready(function(){

....

.........

});

More info: https://community.nintex.com/docs/DOC-6783-simple-javascript-concepts-in-nintex-form

Badge +3

With no changes, I was able to see the value in Edit Mode.  That's all I require at this point, but I do wonder if there's a way to view the field values in Display Mode.

Userlevel 5
Badge +14

in Display mode javascript variables are not instantiated, so to get control's value you need a different way how to identify a control you want to get a value from.

typically it's done by a defining a custom CSS class and then use it as a control's selector.

Userlevel 5
Badge +13

Hi @bbollmann,

 

Can you explain the experience you are wanting with your JavaScript? What could we build in product so you didnt need to use this JavaScript? 


Are you wanting a modal popup triggered from a rule?

 

Cheers,

Euan

Reply