we are using magento multi vendor site
我们正在使用magento多供应商网站
we are using following code to update and cancel price . but once we click on "cancel" button textfield is hiding.
我们正在使用以下代码更新和取消价格。但一旦我们点击“取消”按钮,textfield就隐藏了。
PHTML
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
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();
}
2 个解决方案
#1
3
remove this line $wk_jq(qtyId).hide();
because on cancel you are hiding input field
in function.
删除这条线wk_jq美元(qtyId)hide();因为在取消时,你在函数中隐藏输入字段。
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>
#2
1
*There is a minor mistake you are doing with the Cancel button.*
You are calling hideResetPrice() function on click of cancel button. Just remove onclick="hideResetPrice() function. And let the code be only. This will not hide your text field.
您正在调用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>
#1
3
remove this line $wk_jq(qtyId).hide();
because on cancel you are hiding input field
in function.
删除这条线wk_jq美元(qtyId)hide();因为在取消时,你在函数中隐藏输入字段。
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>
#2
1
*There is a minor mistake you are doing with the Cancel button.*
You are calling hideResetPrice() function on click of cancel button. Just remove onclick="hideResetPrice() function. And let the code be only. This will not hide your text field.
您正在调用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>