Skip to main content
Nintex Community Menu Bar
Solved

How to set default value some option in drop down list look up using JQuery or Javascript

  • July 20, 2017
  • 3 replies
  • 650 views
  • Translate

Forum|alt.badge.img+4

Hi Team,

Is there any way to set some option value to list look up using Jquery or javascript.

205778_pastedImage_1.png

Note: This should not always 0 - NA. But some cases i have to set 1 - Internal Fraud.

Best answer by joseph_cervi

This should do it for you.  This code populates the default value with the selectedindex.  Change the index to the specific option number you want.  

var JS_ControlName_X = JS_ControlName.replace('_hid',"");

NWF$('#'+JS_ControlName_X).prop('selectedIndex',0);

NWF$('#'+JS_ControlName_X).trigger("change");

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+5

This should do it for you.  This code populates the default value with the selectedindex.  Change the index to the specific option number you want.  

var JS_ControlName_X = JS_ControlName.replace('_hid',"");

NWF$('#'+JS_ControlName_X).prop('selectedIndex',0);

NWF$('#'+JS_ControlName_X).trigger("change");

Translate

Forum|alt.badge.img+2
  • 5 replies
  • January 20, 2021
Hi Joseph,
Can you explain this code a little bit more? Not exactly sure what is going on.
Translate

Forum|alt.badge.img+3
joseph_cervi wrote:

This should do it for you.  This code populates the default value with the selectedindex.  Change the index to the specific option number you want.  

 

var JS_ControlName_X = JS_ControlName.replace('_hid',"");

NWF$('#'+JS_ControlName_X).prop('selectedIndex',0);

NWF$('#'+JS_ControlName_X).trigger("change");

I recently upgraded to the latest version of Nintex 2013, April 2024 release and discovered that using this code:

    var CurrencyRetrieved = NWF$('#' + ddlPaymentCurrency + ' option:contains(AUD - Australia Dollar)');
    var CurrencyValue = CurrencyRetrieved.val();
    CurrencyRetrieved.prop('selected', 'selected');
    NWF$("#" + ddlPaymentCurrency).parent().find('input').val(CurrencyValue);
    NWF.FormFiller.Functions.ProcessOnChange(NWF$("#" + ddlPaymentCurrency));

However when I use this code

var ddlPaymentCurrency = ddlPaymentCurrency.replace('_hid',"");
var CurrencyRetrieved = NWF$('#' + ddlPaymentCurrency + ' option:contains(AUD - Australia Dollar)');
var CurrencyValue = CurrencyRetrieved.val();
CurrencyRetrieved.prop('selected', 'selected');
NWF$("#" + ddlPaymentCurrency).parent().find('input').val(CurrencyValue);
NWF.FormFiller.Functions.ProcessOnChange(NWF$("#" + ddlPaymentCurrency));

it works. Can you explain why removing “-hid” from the control name JS declaration makes a difference?

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings