当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Hide update and cancel button after click on update button

问题描述:

We are using this code for updating the price.

Once we click on "update" button it's displaying as like in image.

What we need is once we click on "update" button, then "Update" and "cancel" button should hide. Now once we refresh the page, then only "Update" and "cancel" button is hidden, but it should happen before refeshing the page. I need something like this: https://jsfiddle.net/g1v9x1bt/

For the "cancel" button, it's working fine. Once we click on the "cancel" button, then "Update" and "cancel" button is hiding

<span class="label pro_status">

<?php //echo $products->getPrice(); ?>

<span id="valueprice_<?php echo $products->getId(); ?>"><?php echo $products->getPrice(); ?></span>

<input type = "text" id = "price_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getPrice(); ?>" style = "display:none"/>

<!-- aki 2 -->

<span class="label wk_action" id="edit_link_<?php echo $products->getId(); ?>">

<img onclick="showFieldPrice('<?php echo $products->getId(); ?>'); return false;"

src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>

</span>

<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red;">Updated</p><br/>

<button id="price_update_button_<?php echo $products->getId(); ?>" class="button wk_mp_btn1" onclick="updateFieldPrice('<?php echo $products->getId(); ?>'); return false;" style="display:none" >

<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;" style="display:none" >

<span><span><?php echo $helper->__('Cancel') ?></span></span>

</button>

</span>

script

<script>

function updateFieldPrice(product_id)

{

var priceId = '#price_'+ product_id;

var valueId = '#valueprice_'+ product_id;

var updatedqty = '#updatedprice_'+ product_id;

var editLink = "#price_edit_link_"+ product_id;

var updateButton = "#price_update_button_"+ product_id;

var resetButton = "#price_reset_button"+ product_id;

var url ='<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateFieldPrice/')?>';

$wk_jq(priceId).toggle()

$wk_jq(editLink).hide();

$wk_jq(updateButton).show();

$wk_jq(resetButton).show();

$price = $wk_jq(priceId).val();

jQuery(valueId).html($price);

hideReset(product_id);

网友答案:

So per your requirement, following fiddle will help you.

Element Object

var $updateButton = $wk_jq("#update_button_"+ product_id);

You can disable button using following code:

var $updateButton = $wk_jq("#update_button_"+ product_id);

Reset button object

var $resetButton = $wk_jq("#update_button_"+ product_id);

Disable

Here you are updating disabled property of only update button.

$updateButton.prop('disabled', true);

Hide

$updateButton.hide();
$resetButton.hide();
分享给朋友:
您可能感兴趣的文章:
随机阅读: