1

On Click on the plus icon it will increase the quantity of the corresponding Item and updates that to the MyOrders tab div .

Now on clcik of the Myorders tab div , how can i extract the lastItm_Wrap div whose quantity is greater than 1 ?? so that i can add them to the finalorders

http://jsfiddle.net/673h38g9/4/

my sample code

   $(document).on('click', '.icon-plus', function (e) {
        var value = parseInt($(this).closest('div').find('.QtyInput').val());
        $(this).closest('div').find('.QtyInput').val(value+1);

        var currentsellprice =  parseFloat($(this).parent().prev().data('sellprice')); 
        // get the data "price" of item

        var currentquantity =parseInt($(this).closest('div').find('.QtyInput').val());
        $(this).closest('.lastItm_Wrap').find('.Itm_right_aside .sellprice')
               .text(currentsellprice*currentquantity);

        if (currentquantity>=1) {
            addquantitytoMyordersfooter();
            var subtotalvalue = parseInt($(".myOrderPanel_footer .subtotal")
                                .data('subtotal'));
            subtotalvalue = subtotalvalue + currentsellprice ;

            $(".myOrderPanel_footer .subtotal").data('subtotal',subtotalvalue);
            $(".myOrderPanel_footer .subtotal").text(subtotalvalue)
        }
        displaylogicforfooter();
  });
  • Thanks , but i meant this way http://jsfiddle.net/673h38g9/3/ this is not code , but you can understand what i meant actually –  Feb 23 '15 at 15:38
  • I couldn't find myordersfinaldiv in your Fiddle. Did you mean
    ? Anyway I think it's recommend the to start your custom attributes with data-* http://html5doctor.com/html5-custom-data-attributes/ like this
    – jyrkim Feb 23 '15 at 15:47
  • correct , sorry for the confusion , yes i mean finalorders –  Feb 23 '15 at 15:48
  • No problem, you can use the following selector to set your value: $("div[data-finalorders]").text(subtotalvalue) More info: http://stackoverflow.com/questions/4146502/jquery-selectors-on-custom-data-attributes-on-html5 – jyrkim Feb 23 '15 at 15:52
  • If you dont mind could you please let me know how to fecth the div html of lastItm_Wrap whose quantity is greater than zero . –  Feb 23 '15 at 15:56

1 Answers1

0

I added some logic to you displaylogicforfooter function. This could be used as a starting point. Below data-finalorders div's text is first cleared. After that each div with class lastItm_Wrap is gone through and the QtyInput value is obtained. Currently, there is only alert that prints the quantity if it's more than 1. I hope you find it okay. You still need to add the relevant part that sets the data-finalorders div's content. Fiddle

function displaylogicforfooter()
{    //clear the div value  
     $("div[data-finalorders]").text("");

     $(".lastItm_Wrap").each(function (index) {
         //store lastItm_Wrap div into $elem
        $elem = $(this);
        var qtyValue = $elem.find(".QtyInput").val();

         qtyValue = parseInt(qtyValue);

         //if quantity greater than 1
         if (qtyValue > 1 ) {

             //here you can add your logic - comment out the line below
             alert(qtyValue);

             //if you want to access the lastItm_Wrap div's html, use $elem.html()
             //alternative if you wan't find sth within the div use $elem.find()


             //you can set <div data-finalorders="some text"> text by using the line below
             //just remember to create the div above first :-)
             //$("div[data-finalorders]").text("some text") 

         }

    });

 // more code ....

}
jyrkim
  • 2,849
  • 1
  • 24
  • 33