we are using following code for display Price textfield. we will edit the value and click on update button. if we missly type some numbers in textfields we will click on cancel button ,it will show the original value.
Now cancel button is displaying below text field. what i want is
1)cancel button should display only when we type the updated quantity inside textfield.
2)Once we click on update button , again "cancel" button should hide.
Phtml
<input class="ama1" type = "text" id = "price_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" name= "price[]" value = "<?php echo $products->getPrice(); ?>" style = ""/>
<input type="hidden" name="curr_<?php echo $products->getId(); ?>" id="curr_<?php echo $products->getId(); ?>" value="<?php echo $products->getPrice(); ?>" />
<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
<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>
Javascript
function hideResetPrice(product_id,priceold) {
var qtyId='#price_'+ product_id;
var currprice='#curr_'+ 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( $wk_jq(currprice).val());
$wk_jq(editLink).show();
}
function showFieldPrice(product_id)
{
var qtyId='#price_'+ product_id;
var editLink="#price_edit_link_"+ product_id;
var valueprice="#valueprice_"+ product_id;
var updateButton="#price_update_button_"+ product_id;
var resetButton="#price_reset_button_"+ product_id;
$wk_jq(qtyId).show();
$wk_jq(valueprice).hide();
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(updateButton).prop('disabled', false);//just in case
$wk_jq(resetButton).show();
return false;
}
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…