根据另一个字段的值隐藏字段 [英] Hide a Field Based on the Value from Another Field

查看:87
本文介绍了根据另一个字段的值隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正试图隐藏一个字段基于来自另一个领域的价值。有没有人可以帮我这个? 



我有一个名为Letters的专栏下拉列表中的以下选项:


  1. 业主
  2. < li style ="">经理
  3. 所有者被占用
  4. 所有者非现场
  5. 居民
  6. < li style ="">其他



我有另一个名为Unit Type的列。我想在Letter字段中选择Resident或Other时隐藏Unit Type列。



I没有任何编码经验。我尝试使用谷歌搜索代码并对其进行编辑以满足我的需求,但到目前为止我还没有成功。这是我正在使用的代码并尝试根据我的需求进行更改,但它并没有按照我的要求进行操作。 



< script src =" https://code.jquery.com/jquery-1.7.2.min.js" type =" text / javascript">< / script>


< script type =" text / javascript">


$(document).ready(function(){


//根据下拉选择显示/隐藏列


$(" select [title ='Letter']")。change(function(){


   切换($(this).val()){


      case" Landlord":{


       $('nobr:contains(" Unit Type")')。nearest('tr')。show]();


           break;


     }


     ;   case" Manager":{


  &nbs p;   $('nobr:contains(" Unit Type")')。nearest('tr')。show();


               break;


}


      case" Owner Occupied" ;:{


      $('nobr:contains(" Unit Type" ;)')。最近('tr')。show();


         休息;


}


       case" Owner Offsite":{


      $('nobr:contains(" Unit Type")')。nearest('tr')。show();


        break;


}


      case" Resident":{


      $('nobr:contains(" Unit Type")')。nearest('tr')。hide();


        break;


}


      case" Pre-Screen Mailer":{


      $('nobr:contains(" Unit Type")' ).closest('tr')。hide();


        break;


}


} // end switch


< p style ="">}); //结束更改


}); //结束文件准备


< / script>




解决方案

再添加一个文本字段(计算字段)。它将填充您从下拉列中选择的任何内容。


现在在文本字段而不是下拉列上实现脚本/代码。


Hi,

I'm trying to hide a field based on the value from another field. Is there anyone who could help me with this? 

I have a column called Letters that has the following options in a drop-down:

  1. Landlord
  2. Manager
  3. Owner Occupied
  4. Owner Offsite
  5. Resident
  6. Other

I have another column called Unit Type. I want to hide the Unit Type column when Resident or Other is selected in the Letter field.

I don't have any experience with coding. I tried Googling code and editing it to meet my needs, but so far I've been unsuccessful. This is the code I was working with and trying to change for my needs, but it's not doing what I want it to. 

<script src="https://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>

<script type="text/javascript">

$(document).ready(function(){

//Show/hide columns based on Drop Down Selection

$("select[title='Letter']").change(function() {

  switch($(this).val()) {

    case "Landlord": {

     $('nobr:contains("Unit Type")').closest('tr').show]();

          break;

    }

     case "Manager": {

     $('nobr:contains("Unit Type")').closest('tr').show();

              break;

}

     case "Owner Occupied": {

     $('nobr:contains("Unit Type")').closest('tr').show();

       break;

}

     case "Owner Offsite": {

     $('nobr:contains("Unit Type")').closest('tr').show();

       break;

}

     case "Resident": {

     $('nobr:contains("Unit Type")').closest('tr').hide();

       break;

}

     case "Pre-Screen Mailer": {

     $('nobr:contains("Unit Type")').closest('tr').hide();

       break;

}

} // end switch

}); // end change

}); // end document ready

</script>


解决方案

Add one more text field (calculated field). it would fill whatever you select from your drop down column.

Now implement your script / code on the text field instead of the drop down column.


这篇关于根据另一个字段的值隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆