tags:

views:

171

answers:

1

My jquery code below switches a state dropdownlist out with a state input text box depending on the country that is selected.

It also disables one another depending on which one you select, however I would like to make it not disable the other form field but instead have it clear the contents of "othstate" input box if "usstate" is selected

Is this even possible?

<script>

function locationlist() {
    $('#othstate').hide().attr("disabled", "disabled");
    $('#country').change(function () {
     var val = $(this).val();
     if (val == 224) {
      $('#usstate').val('').show().removeAttr("disabled");
      $('#othstate').hide().attr("disabled", "disabled");
     } else {
      $('#usstate').val('').hide().attr("disabled", "disabled");
      $('#othstate').show().removeAttr("disabled");
     }
    });
}

</script>
+2  A: 

This will clear the contents of othstate:

$('#othstate').val('');
Jataro
thanks I know that is correct because I see it in another part of a code I have but it doesn't work for me, weird
jasondavis
No prob. Did you try modifying your code so the line: $('#othstate').hide().attr("disabled", "disabled");becomes $('#othstate').val('').hide().attr("disabled", "disabled"); ?
Jataro