我们正在使用magento多供应商网站
我们使用以下代码来更新和取消价格。但是一旦我们点击“取消”按钮,文本字段就会隐藏。
PHTML
<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(); ?>" style = ""/>
<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
<button id="price_update_button_<?php echo $products->getId(); ?>" class="update" onclick="updateFieldPrice('<?php echo $products->getId(); ?>'); return false;" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>
<button id="price_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetPrice('<?php echo $products->getId(); ?>'); return false;">
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
</span>
的Javascript
function hideResetPrice(product_id) {
var qtyId='#price_'+ product_id;
var editLink="#price_edit_link_"+ product_id;
var updateButton="#price_update_button_"+ product_id;
var valueprice="#valueprice_"+ product_id;
var resetButton="#price_reset_button_"+ product_id;
$wk_jq(qtyId).hide();
$wk_jq(valueprice).show();
$wk_jq(editLink).show();
$wk_jq(updateButton).hide();
$wk_jq(resetButton).hide();
}
答案 0 :(得分:3)
删除此行$wk_jq(qtyId).hide();
,因为在取消时您隐藏了input field
功能。
function hideResetPrice(product_id,priceold) {
var qtyId='#price_'+ product_id;
var editLink="#price_edit_link_"+ product_id;
var updateButton="#price_update_button_"+ product_id;
var valueprice="#valueprice_"+ product_id;
var resetButton="#price_reset_button_"+ product_id;
$wk_jq(valueprice).show();
$wk_jq(qtyId).val(priceold);
$wk_jq(editLink).show();
}
<?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(); ?>" style = ""/>
<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
<button id="price_update_button_<?php echo $products->getId(); ?>" class="update" onclick="updateFieldPrice('<?php echo $products->getId(); ?>'); return false;" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>
<button id="price_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetPrice('<?php echo $products->getId(); ?>','<?php echo $products->getPrice(); ?>'); return false;">
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
</span>
答案 1 :(得分:1)
*There is a minor mistake you are doing with the Cancel button.*
点击取消按钮后,您调用hideResetPrice()功能。 只需删除onclick =“hideResetPrice()功能。 让代码 只要。 这不会隐藏您的文本字段。
<button id="price_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetPrice('<?php echo $products>getId(); ?>'); return false;">
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>