input中使用oninput为什么不能执行JavaScript
页面代码:<divclass="pe-lineclear"><divclass="pe-name">采购数量:</div><divclass="pe-box"><inpu...
页面代码:
<div class="pe-line clear">
<div class="pe-name">
采购数量:
</div>
<div class="pe-box">
<input type="text"
oninput="searchFreight()"
class="ui-input goodsCount"
placeholder="至少采购10吨以上"
data-bind="value:caigouTon"
id="goodsCount"
name="goodsCount"
style="width: 150px;" />
<span class="pe-n">吨</span>
</div>
</div>
JS代码:
function searchFreight(){
hsFramework.getJSON(urls.host+'actualStuffMall/query/queryTransportFee.do',{
goodsCount:this.caigouTon(),
deliveryPortId:deliveryPortId,
fromProvinceId:fromProvinceId,
fromCityId:fromCityId,
fromAreaId:fromAreaId,
fromStreetId:fromStreetId,
toProvinceId:vm.provinceId(),
toCityId:vm.cityId(),
toAreaId:vm.countyId(),
toStreetId:vm.streetId(),
toCommunityId:vm.communityId()
},function (data) {
var body = data.body;
var feePrice = body.feePrice;
var startPrice = body.startPrice;
var c;
if(feePrice==null){
// document.getElementById(".tips").style.visibility="hidden";//隐藏
c="收货地址不在配送范围之内,您仍可继续下单,后续将有交易员和您线下沟通其他配送方式。"
}else{
// document.getElementById(".tips").style.visibility="visible";//显示
c = '运费: <span class="um-red">'+feePrice+'</span>元/吨(起步价:'+startPrice+'元)';
}
vm.feePrice(c);
});
} 展开
<div class="pe-line clear">
<div class="pe-name">
采购数量:
</div>
<div class="pe-box">
<input type="text"
oninput="searchFreight()"
class="ui-input goodsCount"
placeholder="至少采购10吨以上"
data-bind="value:caigouTon"
id="goodsCount"
name="goodsCount"
style="width: 150px;" />
<span class="pe-n">吨</span>
</div>
</div>
JS代码:
function searchFreight(){
hsFramework.getJSON(urls.host+'actualStuffMall/query/queryTransportFee.do',{
goodsCount:this.caigouTon(),
deliveryPortId:deliveryPortId,
fromProvinceId:fromProvinceId,
fromCityId:fromCityId,
fromAreaId:fromAreaId,
fromStreetId:fromStreetId,
toProvinceId:vm.provinceId(),
toCityId:vm.cityId(),
toAreaId:vm.countyId(),
toStreetId:vm.streetId(),
toCommunityId:vm.communityId()
},function (data) {
var body = data.body;
var feePrice = body.feePrice;
var startPrice = body.startPrice;
var c;
if(feePrice==null){
// document.getElementById(".tips").style.visibility="hidden";//隐藏
c="收货地址不在配送范围之内,您仍可继续下单,后续将有交易员和您线下沟通其他配送方式。"
}else{
// document.getElementById(".tips").style.visibility="visible";//显示
c = '运费: <span class="um-red">'+feePrice+'</span>元/吨(起步价:'+startPrice+'元)';
}
vm.feePrice(c);
});
} 展开
展开全部
IE不支持oninput,要用onpropertychange,但标准浏览器又不支持onpropertychange,所以要把两者结合:
<input type="text"
oninput="searchFreight()"
onpropertychange="searchFreight()"
class="ui-input goodsCount"
placeholder="至少采购10吨以上"
data-bind="value:caigouTon"
id="goodsCount"
name="goodsCount"
style="width: 150px;" />
<input type="text"
oninput="searchFreight()"
onpropertychange="searchFreight()"
class="ui-input goodsCount"
placeholder="至少采购10吨以上"
data-bind="value:caigouTon"
id="goodsCount"
name="goodsCount"
style="width: 150px;" />
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询