0

雇用タイプが契約またはフルタイムの場合にのみ有効txtEmployerにすることは、フルタイムで無効にする必要があります。

<div>
  <select id="SelectEmployment">
    <option value="Select Employment">Employment Type</option>
    <option value="Full-time">Full-time</option>
    <option value="Part-time">Part-time</option>
    <option value="Contract">Contract</option>
    <option value="Fixed term">Fixed term</option>
  </select>
</div>
<div>
  <input type="text" id="txtEmployer" value="Employer" class="txtinline water"/>
</div>
4

4 に答える 4

0

以下のコードを試してください:

$("#SelectEmployment").change(function () {
    if ($(":selected", $(this)).text() == "Contract" || $(":selected", $(this)).text() == "Full-time") {
        $("#txtEmployer").removeAttr("disabled");
    } else {
        $("#txtEmployer").attr("disabled", "disabled");
    }
});
于 2013-03-07T15:45:11.847 に答える
0

これはどうですか?

$("#SelectEmployment").change(function () {
    if ($(this).val() == "Fixed term") {
        $('#txtEmployer').attr("disabled", "disabled");
    }
    else {
        $('#txtEmployer').removeAttr("disabled");
    }
});
于 2013-03-07T15:39:33.067 に答える
0

何かのようなもの

function updateState(val){
    $('#txtEmployer').prop('disabled', !(val == 'Full-time' || val == 'Contract'));
}

$('#SelectEmployment').change(function(){
    var val = $(this).val();
    updateState(val);
});

updateState($('#SelectEmployment').val());

デモ:フィドル

于 2013-03-07T15:46:10.673 に答える
0

フルタイムについては曖昧なので、最初はパートタイムとしています。これを試して :

$(document).ready(function(){
    $('#SelectEmployment').change(function(){
        if($(this).val() == 'Contract' || $(this).val() == 'Part-time') {
            $('#txtEmployer').removeAttr('disabled');
        }
        if($(this).val() == 'Full-time') {
            $('#txtEmployer').attr('disabled', true);
        }
    });
});
于 2013-03-07T15:53:05.883 に答える