0

we are using follwing code display like this "image 1" : http://prntscr.com/8w7f5v :

<td>
     <?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>
      <input type = "text" id = "qty_<?php echo $products->getId(); ?>" name = "qty" value = "<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>" style = "display:none"/>

    <span class = "label wk_action">
      <img onclick = "updateField('<?php echo $products->getId(); ?>'); " 
      src = "<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>    

        <br/>

    <button class="button wk_mp_btn1" title="<?php echo $helper->__('Save') ?>" type="submit" id="save_butn">
    <span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
    </button>



    <button type="reset" class="button wk_mp_btn1" onclick="updateField('<?php echo $products->getId(); ?>');return false;">
    <span><span><?php echo $helper->__('Cancel') ?></span></span>
    </button>
         </td>

if we click on edit button , its displaying like this "image 2" : http://prntscr.com/8w7fdp

what i need is

a)if we click on edit button, than only "Update" & "cancel" button should visible and "Edit" button should hide.

b)Later if we click on "cancel" button, than "Update & cancel" button should hide and "Edit" button should visible.

1 Answer 1

1

Try something like, I am not sure if that work or not

<span class="label wk_action" id="edit_link_<?php echo $products->getId(); ?>">
        <img onclick="updateField('<?php echo $products->getId(); ?>'); return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>  

    <br/>
    <button id="update_button_<?php echo $products->getId(); ?>" class="button wk_mp_btn1" title="<?php echo $helper->__('Save') ?>" type="submit" id="save_butn">
        <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;">
        <span><span><?php echo $helper->__('Cancel') ?></span></span>
    </button>

and change script as per

<script type = "text/javascript" >

        var $wk_jq = jQuery.noConflict();

        function hideReset(product_id) {
            var editLink = "#edit_link_"+ product_id;
            var updateButton = "#update_button_"+ product_id;
            var resetButton = "#reset_button"+ product_id;

            $wk_jq(editLink).show();
            $wk_jq(updateButton).hide();
            $wk_jq(resetButton).hide();
        }

        function updateField(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).toggle()

            $wk_jq(editLink).hide();
            $wk_jq(updateButton).show();
            $wk_jq(resetButton).show();

            $qty = $wk_jq(qtyId).val();

            new Ajax.Request('<?php echo $url ?>', {
                method: 'post',
                parameters: {id: product_id, qty: $qty}
            });
        }
    </script>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.