PHP中调用当前JS获取的值,传递给后台 50
functionchangePrice(type){varqty=document.forms['ECS_FORMBUY'].elements['number'].val...
function changePrice(type)
{
var qty = document.forms['ECS_FORMBUY'].elements['number'].value;
if(type == 1){qty--; }
if(type == 3){qty++; }
if(qty<=0){
$("#reduce").css("background","#797272");
qty=1;
};
if(qty>1){
$("#reduce").css("background","#eee");
}
if(!/^[0-9]*$/.test(qty)){ qty = document.getElementById('back_number').value; }
document.getElementById('goods_number').value = qty;
var attr = getSelectedAttributes(document.forms['ECS_FORMBUY']);
$.get('{:url("goods/price")}', {'id':goodsId,'attr':attr,'number':qty}, function(data){
changePriceResponse(data);
}, 'json');
}
<form action="index.php?m=default&c=flow&a=immediate_buy" method="post">
<input id="goodsNumber" name="goodsNumber" type="hidden" value="">
<input id="goodsId" name="goodsId" type="hidden" value="{$goods.goods_id}">
<input type="submit" value="立即购买">
</form>
如何在这个表单中获取上面changprice中qty的值呢? 展开
{
var qty = document.forms['ECS_FORMBUY'].elements['number'].value;
if(type == 1){qty--; }
if(type == 3){qty++; }
if(qty<=0){
$("#reduce").css("background","#797272");
qty=1;
};
if(qty>1){
$("#reduce").css("background","#eee");
}
if(!/^[0-9]*$/.test(qty)){ qty = document.getElementById('back_number').value; }
document.getElementById('goods_number').value = qty;
var attr = getSelectedAttributes(document.forms['ECS_FORMBUY']);
$.get('{:url("goods/price")}', {'id':goodsId,'attr':attr,'number':qty}, function(data){
changePriceResponse(data);
}, 'json');
}
<form action="index.php?m=default&c=flow&a=immediate_buy" method="post">
<input id="goodsNumber" name="goodsNumber" type="hidden" value="">
<input id="goodsId" name="goodsId" type="hidden" value="{$goods.goods_id}">
<input type="submit" value="立即购买">
</form>
如何在这个表单中获取上面changprice中qty的值呢? 展开
1个回答
展开全部
<form action="index.php?m=default&c=flow&a=immediate_buy" method="post" onSubmit="return changePrice(type)">
<input id="goodsNumber" name="goodsNumber" type="hidden" value="">
<input id="goodsId" name="goodsId" type="hidden" value="{$goods.goods_id}">
<input type="submit" value="立即购买">
<input id="goodsNumber" name="goodsNumber" type="hidden" value="">
<input id="goodsId" name="goodsId" type="hidden" value="{$goods.goods_id}">
<input type="submit" value="立即购买">
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询