Javascript 如何根据另一个表单值动态显示(或不显示)复选框?

Javascript 如何根据另一个表单值动态显示(或不显示)复选框?,javascript,jquery,jqgrid,Javascript,Jquery,Jqgrid,我的目标是在此表单上创建一个复选框,但仅根据下拉列表的值显示它 { //this is the drop down list value key: false, label: 'T.Expediente', name: 'COD_DPTO_ORIGEN', editable: true, edittype: 'select', /*editoptions: { value: $scope.settings.cbGridCodTipExpOp },*/ formatter:

我的目标是在此表单上创建一个复选框,但仅根据下拉列表的值显示它

{
    //this is the drop down list value
    key: false, label: 'T.Expediente', name: 'COD_DPTO_ORIGEN', editable: true,
    edittype: 'select', /*editoptions: { value: $scope.settings.cbGridCodTipExpOp },*/ formatter: 'select', width: 5,
    editrules: { required: false }, editoptions: { 'class': 'bg-required' },
                },
{
    //and this is the checkbox I had to create
    key: false, label: 'Colaborativo', name: 'FLAG_COLABORATIVO', hidden: true, editable: true, edittype: 'checkbox',
    formoptions: { label: '¿Colaborativo?' },
    editrules: { edithidden: true },
    editoptions: { value: "1:0", defaultValue: "0" },
},
仅当下拉列表的值为“13”时,才应显示该复选框

当用户决定向某个表添加新寄存器时,会出现此表单

抱歉,我更改了一些内容,因为我无法显示,但它们与我的问题无关

showNavGrid: true,      // Muestra o no Navgrid.
navTools: { add: true, edit: true, del: true, view: true, refresh: true, search: false },
prmAdd: {
    closeOnEscape: true, closeAfterAdd: true, recreateForm: true,
    id: 'ROWID',
    url: AtUrlValue.XXXXXXXXX
    editData: { __RequestVerificationToken: $rootScope.sAntiForToken },
    beforeShowForm: function (form) {

        $('#xxxxxx', form).show();
        $('#xxxxxx', form).hide();
        $('#xxxxxx', form).attr("disabled", false);
        $('#tr_' + 'xxxx', form).hide();


        //THIS is what i've tried
        if ( $('#COD_DPTO_ORIGEN').val() == "13" ) {
            $('#tr_FLAG_COLABORATIVO', form).show();
            }
        else {
            $('#tr_FLAG_COLABORATIVO', form).hide();
            }

    },

它的工作方式与我的相同,但它只在页面加载时输入if,因为它在showForm之前的事件
中。但我不知道如何动态制作,谢谢

您可以收听列表中的更改事件

$(document).on('change', '#tr_FLAG_COLABORATIVO', function(e){
  //add your code
});

您可以收听列表中的更改事件

$(document).on('change', '#tr_FLAG_COLABORATIVO', function(e){
  //add your code
});