Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textfield is hiding once we click on cancel button

we are using magento multi vendor site

we are using following code to update and cancel price . but once we click on "cancel" button textfield is hiding.

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();
}
like image 377
fresher Avatar asked Dec 17 '15 12:12

fresher


2 Answers

remove this line $wk_jq(qtyId).hide(); because on cancel you are hiding input field in 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>
like image 66
Qaisar Satti Avatar answered Oct 25 '22 10:10

Qaisar Satti


*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.

<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>
like image 40
Pushp Singh Avatar answered Oct 25 '22 10:10

Pushp Singh