The text field is hidden after clicking the cancel button

we use the magento multi vendor website

We use the following code to update and cancel prices. but as soon as we click the "Cancel" button, the text box is hidden.

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(); } 
+6
source share
2 answers

delete this line $wk_jq(qtyId).hide(); because when you cancel, you hide the input field in the function.

 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> 
+3
source
 *There is a minor mistake you are doing with the Cancel button.* 

You can call the hideResetPrice () function by clicking the cancel button. Just remove the onclick = "function hideResetPrice () . And let the code be only. This will not hide your text box.

 <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
source

All Articles