如何清除文本自动完成字段的值

时间:2016-06-13 07:52:35

标签: php

查询详细信息/描述字段自动完成。

SELECT ITEMS
FROM CMS.V_MASTER_COMPEXP 
WHERE USERNAME = '[usr_name]' AND COSTCENTER_CODE = '{CHARGE_CC}' AND PLANT = '{PLANT}'
ORDER BY ITEMS

image of the auto-complete and text field

我需要的情景:

  • 当我更改PLANT时,将清除详细/描述数据或将值设置为空。

  • 当我更改CHARGE TO COST CENTER时,将清除详细信息/描述和PLANT数据或将值设置为空。

1 个答案:

答案 0 :(得分:0)

使用jQuery来执行此操作,例如

<script>
change(element,elementtobechanged)
 {
   if(document.getElementsByName(element)[0].checked)
 {     
   document.getElementsByName(elementtobechanged)[0].disabled  = true;
  }
}
</script>

 <input type="checkbox" name="absolute"  onchange="change(this,'s1');" Absolute</p>
   <div id="s1">
   <div class="demo-section k-content">
    <p style="margin-top: 2em">Start date:</p>
        <input id="start" style="width: 100%;" value=""  onFocus="this.value = '';" onBlur="if (this.value == '') {this.value = '';}" disabled/>
        <p style="margin-top: 2em">End date:</p>
       <input id="end" style="width: 100%;" value="" onFocus="this.value = '';" onBlur="if (this.value == '') {this.value = '';}" disabled/>
    </div>
    </div>
   <input type="checkbox" name="quick"  onchange="change(this,'s2');"                                Quick
    <div id="s2" >
    <select name="quickselect" id="quickselect"  disabled>
    <option value="15">Last 15 minutes</option>
    <option value="12h">Last 12 hour</option>
   <option value="24h">Last 24 hour</option>
   </select>

Jsfiddle