javascript - textfield is hiding once we click on update button, again visible after refresh the page -


we using magento marketplace multi-vendor site, means sellers can sell products through site.

we displaying price in frontend using following code :

phtml

<input onfocus="showpricecancel('<?php echo $products->getid(); ?>');" 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 style="display:none;" 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> 

script

function showpricecancel(p) {               jquery('#price_reset_button_'+p).css('display','block');          };  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;           }   function updatefieldprice(product_id)  {  var priceid = '#price_'+ product_id;  var currprice='#curr_'+ product_id;  var updatedqty = '#updatedprice_'+ product_id;  var url ='<?php echo mage::geturl('marketplace/marketplaceaccount/updatefieldprice/')?>';  $price = $wk_jq(priceid).val();  $wk_jq(currprice).val($price);  new ajax.request(url, {  method: 'post',  parameters: {id: product_id, price: $price},  oncomplete: function (transport) {  //alert(transport.responsetext);   jquery(updatedqty).show().delay(2000).fadeout();   }  });  } 

its displaying : enter image description here

i using similar code , displaying quanity price, once updated quantity clicking on "update" button ,than quantity value become invisible. once refresh page again visible.

phtml

    <input type="text" id="qty_<?php echo $products->getid(); ?>" onkeydown="validatenumbers(event)" class= "ama1" name = "qty " value = "<?php echo (int) mage::getmodel( 'cataloginventory/stock_item')->loadbyproduct($products)->getqty(); ?>"/>  <p id="updatedqty_<?php echo $products->getid(); ?>" style="display:none;color:red;">updated</p> <br/>  <button id="update_button_<?php echo $products->getid(); ?>" class="button wk_mp_btn1" onclick="updatefield('<?php echo $products->getid(); ?>'); return false;" style="display:none">     <span><span style="font-size:12px;"><?php echo $helper->__('update') ?></span></span> </button>  <button id="reset_button_<?php echo $products->getid(); ?>" type="reset" class="cancel" onclick="hidereset('<?php echo $products->getid(); ?>'); return false;" style="display:none">     <span><span><?php echo $helper->__('cancel') ?></span></span> </button> 

script

function hidereset(product_id) {              var qtyid='#qty_'+ product_id;             var editlink="#edit_link_"+ product_id;             var updatebutton="#update_button_"+ product_id;             var resetbutton="#reset_button_"+ product_id;              $wk_jq(qtyid).hide();             $wk_jq(editlink).show();             $wk_jq(updatebutton).hide();             $wk_jq(resetbutton).hide();         }          function showfield(product_id)         {              var qtyid='#qty_'+ product_id;              var editlink="#edit_link_"+ product_id;             var updatebutton="#update_button_"+ product_id;             var resetbutton="#reset_button_"+ product_id;              $wk_jq(qtyid).show();              $wk_jq(editlink).hide();             $wk_jq(updatebutton).show();             $wk_jq(updatebutton).prop('disabled', false);//just in case             $wk_jq(resetbutton).show();              return false;           }         function updatefield(product_id)         {             var qtyid = '#qty_'+ product_id;             var valueid = '#valueqty_'+ product_id;             var updatedqty = '#updatedqty_'+ product_id;               var editlink = "#edit_link_"+ product_id;             var updatebutton = "#update_button_"+ product_id;             var resetbutton = "#reset_button"+ product_id;         var url ='<?php echo mage::geturl('marketplace/marketplaceaccount/updatefield/')?>';              $wk_jq(qtyid).toggle()              $wk_jq(editlink).hide();             $wk_jq(updatebutton).show();             $wk_jq(resetbutton).show();              $qty = $wk_jq(qtyid).val();             jquery(valueid).html($qty);             hidereset(product_id);              new ajax.request(url, {                 method: 'post',                 parameters: {id: product_id, qty: $qty},                 oncomplete: function (transport) {                     //alert(transport.responsetext);                       jquery(updatedqty).show().delay(2000).fadeout();                      $updatebutton.prop('disabled', false);                      $wk_jq(qtyid).setvalue($qty);                    }             });         } 

remove hidereset(product_id); because hiding field remove $wk_jq(qtyid).toggle(); toggle hide field if showing , change $wk_jq(updatebutton).show(); $wk_jq(updatebutton).hide();


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -