我们正在使用magento多供应商网站。
我们使用以下代码在前端显示价格和特价
我正面临一些问题
1)一旦我们编辑价格和特价文本字段并点击页面上的任何位置,就会更新其值。
只有在点击更新按钮时才会更新。
2)如果我们只编辑价格,则“更新”消息会在“价格和特价”下显示
3)一旦光标在文本字段中,我们就无法刷新页面。
价格 - HTMl
<span class="label pro_status">
<?php //echo $products->getPrice(); ?>
<input class="ama1" type = "text" id = "price_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getPrice(); ?>" onchange="updateFieldPrice('<?php echo $products->getId(); ?>')" style = ""/>
<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
</span>
特价 - HTML
<span class="label pro_status">
<?php ?>
<input class="ama1" type = "text" id = "specialprice_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getSpecialPrice(); ?>" onchange="updateFieldSpecialPrice('<?php echo $products->getId(); ?>')" style = ""/>
<p id="updatedspecialprice_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
</span>
价格 - Javascript
function updateFieldPrice(product_id)
{
var priceId = '#price_'+ product_id;
var updatedqty = '#updatedprice_'+ product_id;
var url ='<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateFieldPrice/')?>';
$price = $wk_jq(priceId).val();
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, price: $price},
onComplete: function (transport) {
//alert(transport.responseText);
jQuery(updatedqty).show().delay(2000).fadeOut();
}
});
}
特价 - Javascript
function updateFieldSpecialPrice(product_id)
{
var priceId = '#specialprice_'+ product_id;
var updatedqty = '#updatedspecialprice_'+ product_id;
var url ='<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateFieldSpecialPrice/')?>';
$price = $wk_jq(priceId).val();
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, price: $price},
onComplete: function (transport) {
//alert(transport.responseText);
jQuery(updatedqty).show().delay(2000).fadeOut();
}
});
}
答案 0 :(得分:0)
使用onblur
价
<span class="label pro_status">
<?php //echo $products->getPrice(); ?>
<input class="ama1" type = "text" id = "price_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getPrice(); ?>" onblur="updateFieldPrice('<?php echo $products->getId(); ?>')" style = ""/>
<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
</span>
特价
<input class="ama1" type = "text" id = "specialprice_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getSpecialPrice(); ?>" onblur="updateFieldSpecialPrice('<?php echo $products->getId(); ?>')" style = ""/>