AnsweredAssumed Answered

Nintex Forms. JavaScript: set value to dropdown control by Text.

Question asked by civilgb on Nov 22, 2018
Latest reply on Nov 22, 2018 by civilgb

I need to set by JavaScript a value to a dropdown field control knowing only Text.

For example, There is a dropdown control that has 3 values - One, Two, Three. I need to set my value to Three by JavaScript. I found that aricle Custom Script on O365 and according to this I can set value only knowing Id, but I want set value not by Id but by Text.

 

That works:

  1. NWF.FormFiller.Events.RegisterAfterReady(function () {  
  2.     NWF$('#' + ddlStaff).on('change'function (e) {  
  3.         if (e.originalEvent == undefined) {  
  4.             if (this.value == "") {  
  5.                 this.value = "1";  
  6.             }  
  7.         }  
  8.     });  
  9. });

 

But like this it does not work:

  1. NWF.FormFiller.Events.RegisterAfterReady(function () {  
  2.     NWF$('#' + ddlStaff).on('change'function (e) {  
  3.         if (e.originalEvent == undefined) {  
  4.             if (this.value == "") {  
  5.                 this.value = "Three";  
  6.             }  
  7.         }  
  8.     });  
  9. });

Any ideas how to set value by Text?

Outcomes