Select value from DD with JS

  • 26 November 2015
  • 4 replies
  • 5 views

Badge +3

Unfortunately, I am not a java/vb developer. Maybe someone could be so kind and help me? I have two DD and I want to set the second one to NULL if the value of the first DD is not NULL (“Please select a value…”). How can i solve that ...with JS? I appreciate every suggestion!

 

 

What I tried …

 

 

var hwt =document.getElementById("DD_HardwareType");

var mhl =document.getElementById("DD_MonitorHelp");

 

if (hwt.selectedIndex != 'null') {

mhl.selectedIndex = 'null';

}

 

Tia!


4 replies

Badge +7

Hi,

Please can you tell me what type of field you are using as your drop-down? Is it a Choice? And is it connected to a list column?

Thanks

Jan

Badge +3

It is a "Drop down List". Source list is Hardware_Type (DD_HardwareType) and MonitorHelp (DD_MonitorHelp). At the moment the DD is not connected to a list.

Tia!

Badge +7

Thanks,

 

The following steps should get this working for you.

 

Default settings for HardwareType field in my test example (will be different for you):

146524_pastedImage_3.png

Default settings for MonitorType field in my test example:

146523_pastedImage_2.png

 

1. In the settings of your Hardware_Type field expand Advanced section and store the Client ID in a javascript variable called DD_HardwareType

146521_pastedImage_0.png

2. In the settings of you MonitorHelp field expand the Advanced section and store the Client ID in a javascript variable called DD_MonitorHelp

146522_pastedImage_1.png

3. Then in Form settings - Custom JavaScript section paste the following:

 

 

 

 

function setMonitorType(myControl) {
    var nullValue = "Please select a value...";
    if (myControl.val() != nullValue) {       
        NWF$("#" + DD_MonitorHelp).val(nullValue);
    }
}

NWF.FormFiller.Events.RegisterAfterReady(function () {
    NWF$("#" + DD_HardwareType).on("change", function (event) { setMonitorType(NWF$(this)); });
});

Badge +3

Works perfectly! Thank you!

Reply