在Javascript中清除文本框检查复选框

时间:2013-04-15 13:48:26

标签: javascript checkbox dynamics-crm-2011 xrm

我有一些javascript控制MS动态2011表格上的逻辑。

当我单击一个复选框(默认选中)时,有一个允许您输入数据的文本框。取消选中此框后,文本框将消失。但是,当我重新检查复选框时,文本框会重新出现(根据需要),但仍然有任何先前输入的文本,仍然存储。如何确保文本框设置为null?包含的代码段。

感谢。

function SetupForm() {
     debugger;
     HA_OtherText();
 }

 function HA_OtherText() {
     Xrm.Page.getAttribute("ha_other").getValue();
     if (Xrm.Page.getAttribute("ha_other").getValue() == true) {
         Xrm.Page.ui.controls.get("ha_othertext").setVisible(true);
     } else {
         Xrm.Page.ui.controls.get("ha_othertext").setVisible(false);
     }
 }

1 个答案:

答案 0 :(得分:1)

您所做的只是将字段设置为可见或可见,如果要“清除”它,则需要将字段值设置为null:

function HA_OtherText()
{
  Xrm.Page.getAttribute("ha_other").getValue();
  if (Xrm.Page.getAttribute("ha_other").getValue() == true) 
  {
    Xrm.Page.ui.controls.get("ha_othertext").setVisible(true);
  }
  else
  {
    Xrm.Page.ui.controls.get("ha_othertext").setVisible(false);
    Xrm.Page.getAttribute("ha_othertext").setValue(null);
  }
} 
相关问题