<input type="hidden" name="CUSTOMER_ID" id="CUSTOMER_ID" value="<!--{$data.CUSTOMER_ID}-->" />
<input type="text" readonly id="CUSTOMER_NAME" name="CUSTOMER_NAME" value="<!--{$data.CUSTOMER_NAME}-->"/>
<a href="javascript:;" class="btn btn-mini btn-info" id="abcde" οnclick="crm.choose('/Crm/Customer/search','CUSTOMER_ID,CUSTOMER_NAME');getCustomerId();">添加</a>
<a href="javascript:;" class="btn btn-mini" οnclick="crm.clear('CUSTOMER_ID,CUSTOMER_NAME')">清空</a>
上述代码中通过onclick点击弹窗子页面查询回填至该页面中的CUSTOMER_ID和CUSTOMER_NAME字段,但是要监听该CUSTOMER_ID字段,而子窗口禁止修改,因此只能在当前页面做调整。
那只能循环监听页面了。
因此就产生了下面的js代码
<script language="javascript">
var _interval;
var _const_num=0;
function getCustomerId(){
value1 = $('#CUSTOMER_ID').val();
if(value1!=''&&_const_num!=value1){
alert(value1);
clearTimeout(_interval);
_const_num = value1;
return false;
}else{
_interval = setTimeout(getCustomerId,1000);
return false;
}
}
</script>