Question: I'm using Eric Hynds' awesome drop down plugin, but I need to use the enable/disable function on multiple dropdowns. The form I will be building is very complex, and multiple dropdowns will be enable by nice Jquery sliders.

<http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/#enabledisable>

The code below has a var in it that I am not quite sure what it's doing given there are not multiple drop downs already. Any help on how to make this happen? Below is the tiny javascript on the page and the trigger. **I need to have separate buttons so I can trigger different dropdowns**, but I'm not seeing how to do it with the code right now.

```
var $widget = $("select").multiselect(), 
    state = true;

$("#toggle-disabled").click(function(){
   state = !state;
   $widget.multiselect(state ? 'disable' : 'enable');
});

```

And then I am using another plugin which converts list/input items into sliders, so if it looks weird I'm toggling off of list, that's because it's the only way to catch the mouse event that way. :P

```
<li class="toggle-disabled"><label for="family">Family Medicine </label><input type="checkbox" id="family" name="family" />

```

Answer: 
It's difficult to understand what you're trying to do with your code.

You want the text input to change its value only if the select box has "IT" selected? 

Why are you setting a `change` handler on the text input?

Why iterate through a select box's options if it's a single select? Just set the text input with the selected option's value, e.g.,

```
$(function() {
  var $billingCountry = $('#billing_country');

  $billingCountry.change(function() {
    var $country = $('#billing_country option:selected');
    fieldCheck($country.val());
  });

  function fieldCheck(country) {
    var $element = $('#woocommerce_cf_piva');
    if ($country !== 'IT') {
      return;
    }

    $element.val(country);
  }
});

```

<https://jsfiddle.net/davelnewton/w5deffvk/>

*Edits*

* Naming conventions changed to reflect typical JS
	+ Non-constructor function names start with lower-case
	+ Non-JQ element vars don't get a leading `$`
* Country value used as guard clause rather than nesting logic
	+ This code is trivial, but nesting can make things harder to reason about
You have two problems:

1. `input` tag does not have `onchange` event; you should use `onkeydown` instead;
2. you should assign events before `if` conditions.