Question (b) encountered in three stages

The method of addition and subtraction jquery realize cart

When the stock reaches a maximum when the database pops up

js code as follows

$ (function () {
                 var T = $ ( " #quantity " ); 
                $ ( " #add " ) .click (function () {
                     IF (the parseInt (t.val ()) == (Stock $ {})) {
                          // when $ ( "# min") is 1, $ ( "# min" ) unreadable state 
                        Alert ( ' has reached the maximum stock ' ) 
                    } the else { 
                        t.val (the parseInt (t.val ()) ); 
                        t.val (the parseInt (t.val ()) + 1 ); 
                    } 
                                    // when adding a press, release $ ( "# min") Unreadable state
                    setTotal (); 
                }) 
                $ ( " #min " ) .click (function () {
                     IF (the parseInt (t.val ())> 1 ) {                      // determines if the number is greater than 1 may be reduced 
                        t.val (parseInt (t.val ()) - . 1 ) 
                    } the else { 
                        $ ( " #min " ) .attr ( " Disabled " , " Disabled " )         // when $ ( "# min") is 1, $ ( "# min ") Unreadable state 
                        Alert ( 'Minimum number. 1 ' ) 
                    } 

                    setTotal (); 
                })

  Shoe size selected when the code is as follows ajax

$("#code38").on('click',function () {
                var bb = $("#code38").val();
                var imga= $("#imga").attr('src');
                var  c=$('#names').text();
                var  jiage=$('#jiage').text();
                var yanse=$("#yanse").text();
                where total=$("#total").text();
                var quantity=$("#quantity").val();
                var style = jiage *quantity
                // console.log(style);
                $('#cc').on('click',function () {
                    $.ajax({
                        type: "post",
                        url: "{:url('admin/details/dda')}",
                        data: {
                            'bb':bb,
                            'c':c,
                            'jiage':jiage,
                            'yanse':yanse,
                            'total':total,
                            'style':style,
                            'imga':imga,
                            'quantity':quantity
                        },
                        dataType: "json"
                    })
                })

            })

php code as follows

 public function  dda(Request $request){

        $desc = $request->param('jiage');
        $title = $request->param('bb');
        $name = $request->param('c');
        $link = $request->param('yanse');
        $total = $request->param('style');
        $imga = $request->param('imga');
        $quantity = $request->stop ( 'quantity');

//        $style = $request->param('style');


        $Comm = new  Comm();
        $Comm->name = $name;
        $Comm->title = $title;
        $Comm->link = $link;
        $Comm->desc = $desc;
        $Comm->style = $total;
        $Comm->path = $imga;
        $Comm->num = $quantity;
        $res = $Comm->save();


        if ($res>0){
            $this->success('成功1','index/Details/index');
        }else{
            $this->error('失败1', 'index/Details/index');
        }
    }

 

Guess you like

Origin www.cnblogs.com/LQK157/p/11457253.html