精华内容
下载资源
问答
  • 自定义组件:数量,带减少增加按钮 转载,但是忘记出处了,现在项目中暂时不用,所以记录一下 1.xml 主要布局view_amount.xml <?xml version="1.0" encoding="utf-8"?> &...

    自定义组件:数量,带减少增加按钮
    转载,但是忘记出处了,现在项目中暂时不用,所以记录一下
    1.xml
    主要布局view_amount.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:divider="@drawable/divider"
        android:background="@drawable/bg_amount_layout"
        android:showDividers="middle"
        android:orientation="horizontal">
    
        <Button
            android:id="@+id/btnDecrease"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="@drawable/btn_amount"
            android:text="-"/>
    
        <EditText
            android:id="@+id/etAmount"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:minWidth="60dp"
            android:layout_weight="2"
            android:background="@null"
            android:inputType="number"
            android:gravity="center"
            android:text="1"/>
    
        <Button
            android:id="@+id/btnIncrease"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="@drawable/btn_amount"
            android:text="+"/>
    </LinearLayout>
    

    样式:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <declare-styleable name="AmountView">
            <!-- 左右2边+-按钮的宽度 -->
            <attr name="btnWidth" format="dimension" />
            <!-- 中间TextView的宽度 -->
            <attr name="tvWidth" format="dimension" />
            <!--<attr name="tvColor" format="color"/>-->
            <attr name="tvTextSize" format="dimension"/>
            <attr name="btnTextSize" format="dimension"/>
        </declare-styleable>
    </resources>
    

    bg_amount_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#FFFFFF" />
        <stroke
            android:width="1dp"
            android:color="@color/divider" />
        <padding
            android:bottom="1dp"
            android:left="1dp"
            android:right="1dp"
            android:top="1dp" />
    </shape>

    btn_amount.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector
      xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true" android:drawable="@color/divider" />
        <item android:state_enabled="false" android:drawable="@color/divider" />
        <item android:drawable="@android:color/white" />
    </selector>

    2.view

    package com.junmp.steel.view;
    
    import android.content.Context;
    import android.content.res.TypedArray;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.util.AttributeSet;
    import android.util.TypedValue;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.LinearLayout;
    
    import com.junmp.steel.R;
    
    /**
     * 自定义组件:购买数量,带减少增加按钮
     * Created by hiwhitley on 2016/7/4.
     */
    public class AmountView extends LinearLayout implements View.OnClickListener, TextWatcher {
    
        private static final String TAG = "AmountView";
        private int amount = 1; //购买数量
        private int goods_storage = 1; //商品库存
    
        private OnAmountChangeListener mListener;
    
        private EditText etAmount;
        private Button btnDecrease;
        private Button btnIncrease;
    
        public AmountView(Context context) {
            this(context, null);
        }
    
        public AmountView(Context context, AttributeSet attrs) {
            super(context, attrs);
    
            LayoutInflater.from(context).inflate(R.layout.view_amount, this);
            etAmount = (EditText) findViewById(R.id.etAmount);
            btnDecrease = (Button) findViewById(R.id.btnDecrease);
            btnIncrease = (Button) findViewById(R.id.btnIncrease);
            btnDecrease.setOnClickListener(this);
            btnIncrease.setOnClickListener(this);
            etAmount.addTextChangedListener(this);
    
            TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.AmountView);
            int btnWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnWidth, LayoutParams.WRAP_CONTENT);
            int tvWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvWidth, 80);
            int tvTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvTextSize, 0);
            int btnTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnTextSize, 0);
            obtainStyledAttributes.recycle();
    
            LayoutParams btnParams = new LayoutParams(btnWidth, LayoutParams.MATCH_PARENT);
            btnDecrease.setLayoutParams(btnParams);
            btnIncrease.setLayoutParams(btnParams);
            if (btnTextSize != 0) {
                btnDecrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
                btnIncrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
            }
    
            LayoutParams textParams = new LayoutParams(tvWidth, LayoutParams.MATCH_PARENT);
            etAmount.setLayoutParams(textParams);
            if (tvTextSize != 0) {
                etAmount.setTextSize(tvTextSize);
            }
        }
    
        public void setOnAmountChangeListener(OnAmountChangeListener onAmountChangeListener) {
            this.mListener = onAmountChangeListener;
        }
    
        public void setGoods_storage(int goods_storage) {
            this.goods_storage = goods_storage;
        }
    
        @Override
        public void onClick(View v) {
            int i = v.getId();
            if (i == R.id.btnDecrease) {
                if (amount > 1) {
                    amount--;
                    etAmount.setText(amount + "");
                }
            } else if (i == R.id.btnIncrease) {
                if (amount < goods_storage) {
    
                }else{
                    amount++;
                    etAmount.setText(amount + "");
                }
            }
    
            etAmount.clearFocus();
    
            if (mListener != null) {
                mListener.onAmountChange(this, amount);
            }
        }
    
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
    
        }
    
        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().isEmpty())
                return;
            amount = Integer.valueOf(s.toString());
            if (amount > goods_storage || amount == goods_storage) {
            }else{
                etAmount.setText(goods_storage + "");
                return;
            }
    
            if (mListener != null) {
                mListener.onAmountChange(this, amount);
            }
        }
    
    
        public interface OnAmountChangeListener {
            void onAmountChange(View view, int amount);
        }
    
    }
    
    展开全文
  • 我的jquery代码如下,但是我点击增加后这个表格的所有数量都增加了,怎样让当前行的数量增加呀? <script type="text/javascript">function add(){$('[id=count]').each(function (){var count=$(this).text();co=...
  • jquery点击按钮淡出淡进动画增加积分数量效果 jquery点击按钮淡出淡进动画增加积分数量效果
  • 对于大多数的商城APP项目,都会有商品数量增加,减少按钮,对此记录下封装:public class AmountView extends LinearLayout implements View.OnClickListener, TextWatcher { private static final String TAG =...
    对于大多数的商城APP项目,都会有商品数量的增加,减少按钮,对此记录下封装:
    public class AmountView extends LinearLayout implements View.OnClickListener, TextWatcher {
    
        private static final String TAG = "AmountView";
        private int position=-1;
    
        private int amount = 0; //购买数量
        private int goods_storage = 100; //商品库存
        private EditText etAmount;
        private Button btnDecrease;
        private Button btnIncrease;
    
        public AmountView(Context context) {
            this(context, null);
        }
    
        public AmountView(Context context, AttributeSet attrs) {
            super(context, attrs);
            //组件布局
            LayoutInflater.from(context).inflate(R.layout.view_amount, this);
            etAmount = (EditText) findViewById(R.id.etAmount);
            btnDecrease = (Button) findViewById(R.id.btnDecrease);
            etAmount.setVisibility(GONE);
            btnDecrease.setVisibility(GONE);
            btnIncrease = (Button) findViewById(R.id.btnIncrease);
            btnDecrease.setOnClickListener(this);
            btnIncrease.setOnClickListener(this);
            etAmount.addTextChangedListener(this);
            etAmount.setFocusable(false);
        }
    
    
        /**
         * 位置
         * @param position
         */
        public void setPosition(int position) {
            this.position = position;
        }
    
        /**
         * 设置库存方法
         * @param goods_storage
         */
        public void setGoods_storage(int goods_storage) {
            this.goods_storage = goods_storage;
        }
    
        /**
         * 获取数量
         * @return
         */
        public int getAmount() {
            return amount;
        }
    
        /**
         * 设置数量
         * @param amount
         */
        public void setAmount(int amount) {
            this.amount = amount;
            etAmount.setText(this.amount + "");
            if (this.amount>=0){
                etAmount.setVisibility(VISIBLE);
                btnDecrease.setVisibility(VISIBLE);
            }
        }
    
        /**
         * 增加,减少事件监听
         * @param v
         */
        @Override
        public void onClick(View v) {
            int i = v.getId();
            if (i == R.id.btnDecrease) {
                if (amount > 0) {
                    amount--;
                    etAmount.setText(amount + "");
                    if (amount==0){
                        amount=1;
    
    //                    etAmount.setVisibility(GONE);
    //                    btnDecrease.setVisibility(GONE);
                    }
                }
            } else if (i == R.id.btnIncrease) {
                if (amount < goods_storage) {
                    amount++;
                    etAmount.setText(amount + "");
                    if (amount>=0){
                        etAmount.setVisibility(VISIBLE);
                        btnDecrease.setVisibility(VISIBLE);
                    }
                }
            }
    
            etAmount.clearFocus();
    
            if (mListener != null) {
                mListener.onAmountChange(this, amount,position);
            }
        }
    
        /**
         * 数量变化监听
         * @param s
         * @param start
         * @param count
         * @param after
         */
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
    
        }
    
        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().isEmpty())
                return;
            amount = Integer.valueOf(s.toString());
            if (amount > goods_storage) {
                etAmount.setText(goods_storage + "");
                return;
            }
    
        }
    
        /**
         * 自定义接口 监听数量变化,
         */
        private OnAmountChangeListener mListener;
    
        public interface OnAmountChangeListener {
            void onAmountChange(View view, int amount,int position);
        }
    
        public void setOnAmountChangeListener(OnAmountChangeListener onAmountChangeListener) {
            this.mListener = onAmountChangeListener;
        }
    }


    组件布局:(备注:增加减少的按钮的背景图,可自行设置,这里就不写了)
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:showDividers="middle"
        android:orientation="horizontal">
    
        <Button
            android:id="@+id/btnDecrease"
            android:layout_width="20dp"
            android:layout_height="21dp"
            android:layout_weight="1"
            android:gravity="center"
            android:background="@mipmap/minus"/>
    
        <EditText
            android:id="@+id/etAmount"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginRight="9dp"
            android:layout_marginLeft="9dp"
            android:background="@null"
            android:inputType="number"
            android:gravity="center"
            android:textSize="15sp"
            android:textColor="@color/color_red_del"
            android:text="0"/>
    
        <Button
            android:id="@+id/btnIncrease"
            android:layout_width="20dp"
            android:layout_height="21dp"
            android:layout_weight="1"
            android:gravity="center"
            android:background="@mipmap/add"/>
    </LinearLayout>
    

    效果图:


    展开全文
  • NumberButton, 购物车商品数量增加和减少控制按钮
  • 饿了么商品购买按钮,刚开始点击的时候按钮展开,点击“+”增加数量,点击“-”减少数量,当数量变为0的时候按钮收拢为一个普通的按钮 [注意:本资源来自网络,如有侵权,请联系我删除,谢谢。]
  • 主要介绍了html在消息按钮增加数量角标的实现代码,需要的朋友可以参考下
  • public class AmountView extends LinearLayout implements View.OnClickListener, TextWatcher { private static final String TAG = "AmountView"; private int amount = 1; //购买数量 private int goods_s
    public class AmountView extends LinearLayout implements View.OnClickListener, TextWatcher {
    
        private static final String TAG = "AmountView";
        private int amount = 1; //购买数量
        private int goods_storage = 1; //商品库存
    
        private OnAmountChangeListener mListener;
    
        private EditText etAmount;
        private Button btnDecrease;
        private Button btnIncrease;
    
        public AmountView(Context context) {
            this(context, null);
        }
    
        public AmountView(Context context, AttributeSet attrs) {
            super(context, attrs);
    
            LayoutInflater.from(context).inflate(R.layout.view_amount, this);
            etAmount = (EditText) findViewById(R.id.etAmount);
            btnDecrease = (Button) findViewById(R.id.btnDecrease);
            btnIncrease = (Button) findViewById(R.id.btnIncrease);
            btnDecrease.setOnClickListener(this);
            btnIncrease.setOnClickListener(this);
            etAmount.addTextChangedListener(this);
    
            TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.AmountView);
            int btnWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnWidth, LayoutParams.WRAP_CONTENT);
            int tvWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvWidth, 80);
            int tvTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvTextSize, 0);
            int btnTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnTextSize, 0);
            obtainStyledAttributes.recycle();
    
            LayoutParams btnParams = new LayoutParams(btnWidth, LayoutParams.MATCH_PARENT);
            btnDecrease.setLayoutParams(btnParams);
            btnIncrease.setLayoutParams(btnParams);
            if (btnTextSize != 0) {
                btnDecrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
                btnIncrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
            }
    
            LayoutParams textParams = new LayoutParams(tvWidth, LayoutParams.MATCH_PARENT);
            etAmount.setLayoutParams(textParams);
            if (tvTextSize != 0) {
                etAmount.setTextSize(tvTextSize);
            }
        }
    
        public void setOnAmountChangeListener(OnAmountChangeListener onAmountChangeListener) {
            this.mListener = onAmountChangeListener;
        }
    
        public void setGoods_storage(int goods_storage) {
            this.goods_storage = goods_storage;
        }
    
        @Override
        public void onClick(View v) {
            int i = v.getId();
            if (i == R.id.btnDecrease) {
                if (amount > 1) {
                    amount--;
                    etAmount.setText(amount + "");
                }
            } else if (i == R.id.btnIncrease) {
                if (amount < goods_storage) {
                    amount++;
                    etAmount.setText(amount + "");
                }
            }
    
            etAmount.clearFocus();
    
            if (mListener != null) {
                mListener.onAmountChange(this, amount);
            }
        }
    
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
    
        }
    
        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().isEmpty())
                return;
            amount = Integer.valueOf(s.toString());
            if (amount > goods_storage) {
                etAmount.setText(goods_storage + "");
                return;
            }
    
            if (mListener != null) {
                mListener.onAmountChange(this, amount);
            }
        }
    
    
        public interface OnAmountChangeListener {
            void onAmountChange(View view, int amount);
        }
    
    }
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:divider="@drawable/divider"
        android:background="@drawable/bg_amount_layout"
        android:showDividers="middle"
        android:orientation="horizontal">
    
        <Button
            android:id="@+id/btnDecrease"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="@drawable/btn_amount"
            android:text="-"/>
    
        <EditText
            android:id="@+id/etAmount"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:minWidth="60dp"
            android:layout_weight="2"
            android:background="@null"
            android:inputType="number"
            android:gravity="center"
            android:text="1"/>
    
        <Button
            android:id="@+id/btnIncrease"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="@drawable/btn_amount"
            android:text="+"/>
    </LinearLayout>
    public class MainActivity extends AppCompatActivity {
        private AmountView mAmountView;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            mAmountView = (AmountView) findViewById(R.id.amount_view);
            mAmountView.setGoods_storage(50);
            mAmountView.setOnAmountChangeListener(new AmountView.OnAmountChangeListener() {
                @Override
                public void onAmountChange(View view, int amount) {
                    Toast.makeText(getApplicationContext(), "Amount=>  " + amount, Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
        <tes.demp3.AmountView
            android:id="@+id/amount_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </tes.demp3.AmountView>

    在drawable下三个文件:
    bg_amount_layout,btn_amount,divider.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#FFFFFF" />
        <stroke
            android:width="1dp"
            android:color="@color/divider" />
        <padding
            android:bottom="1dp"
            android:left="1dp"
            android:right="1dp"
            android:top="1dp" />
    </shape>
    <selector
      xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true" android:drawable="@color/divider" />
        <item android:state_enabled="false" android:drawable="@color/divider" />
        <item android:drawable="@android:color/white" />
    </selector>
    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <size
            android:width="0.5dp"/>
        <solid android:color="@color/divider"/>
    </shape>

    atttrs.xml:

    <resources>
        <declare-styleable name="AmountView">
            <!-- 左右2边+-按钮的宽度 -->
            <attr name="btnWidth" format="dimension" />
            <!-- 中间TextView的宽度 -->
            <attr name="tvWidth" format="dimension" />
            <!--<attr name="tvColor" format="color"/>-->
            <attr name="tvTextSize" format="dimension"/>
            <attr name="btnTextSize" format="dimension"/>
        </declare-styleable>
    </resources>

    colors.xml:

    <resources>
        <color name="colorPrimary">#3F51B5</color>
        <color name="colorPrimaryDark">#303F9F</color>
        <color name="colorAccent">#FF4081</color>
        <color name="divider">#ffd2d2d2</color>
    </resources>
    展开全文
  • ecshop商品页购买数量加减按钮ecshop购物车页加减按钮插件 默认模版为例详细教程: 找到flow.php里的如下代码 elseif ($_REQUEST['step'] == 'update_cart') { if (isset($_POST['goods_number']) &&...

    ecshop商品页购买数量加减按钮ecshop购物车页加减按钮插件

    默认模版为例详细教程:

    找到flow.php里的如下代码

    elseif ($_REQUEST['step'] == 'update_cart')
        {
            if (isset($_POST['goods_number']) && is_array($_POST['goods_number']))
            {
                flow_update_cart($_POST['goods_number']);
            }
            show_message($_LANG['update_cart_notice'], $_LANG['back_to_cart'], 'flow.php');
            exit;
        }  

    修改成:

    elseif ($_REQUEST['step'] == 'update_cart')
    {
        if (isset($_POST['goods_number']) && is_array($_POST['goods_number']))
        {
            flow_update_cart($_POST['goods_number']);
        }
    ecs_header("Location: flow.php?step=cart\n"); 
        show_message($_LANG['update_cart_notice'], $_LANG['back_to_cart'], 'flow.php');
        exit;
    }  

    一、商品页

    打开:goods.dwt

    {* 包含脚本文件 *}
    {insert_scripts files='common.js'}下面这段:

    <script type="text/javascript">
    function $id(element) {
      return document.getElementById(element);
    }
    //切屏--是按钮,_v是内容平台,_h是内容库
    function reg(str){
      var bt=$id(str+"_b").getElementsByTagName("h2");
      for(var i=0;i<bt.length;i++){
        bt[i].subj=str;
        bt[i].pai=i;
        bt[i].style.cursor="pointer";
        bt[i].οnclick=function(){
          $id(this.subj+"_v").innerHTML=$id(this.subj+"_h").getElementsByTagName("blockquote")[this.pai].innerHTML;
          for(var j=0;j<$id(this.subj+"_b").getElementsByTagName("h2").length;j++){
            var _bt=$id(this.subj+"_b").getElementsByTagName("h2")[j];
            var ison=j==this.pai;
            _bt.className=(ison?"":"h2bg");
          }
        }
      }
      $id(str+"_h").className="none";
      $id(str+"_v").innerHTML=$id(str+"_h").getElementsByTagName("blockquote")[0].innerHTML;
    }

    </script>

    修改成:

    <script type="text/javascript">
    function $id(element) {
      return document.getElementById(element);
    }
    //切屏--是按钮,_v是内容平台,_h是内容库
    function reg(str){
      var bt=$id(str+"_b").getElementsByTagName("h2");
      for(var i=0;i<bt.length;i++){
        bt[i].subj=str;
        bt[i].pai=i;
        bt[i].style.cursor="pointer";
        bt[i].οnclick=function(){
          $id(this.subj+"_v").innerHTML=$id(this.subj+"_h").getElementsByTagName("blockquote")[this.pai].innerHTML;
          for(var j=0;j<$id(this.subj+"_b").getElementsByTagName("h2").length;j++){
            var _bt=$id(this.subj+"_b").getElementsByTagName("h2")[j];
            var ison=j==this.pai;
            _bt.className=(ison?"":"h2bg");
          }
        }
      }
      $id(str+"_h").className="none";
      $id(str+"_v").innerHTML=$id(str+"_h").getElementsByTagName("blockquote")[0].innerHTML;
    }


    //实际只是增加了这部分
    function del(){
            var num = document.getElementById("number");
            var n = parseInt(num.value);
            if(n-1<=0){
                    alert("必须选择一个商品");
            }else{
                    num.value = n-1;
            }
    }
    function add(){
            var num = document.getElementById("number");
            var n = parseInt(num.value);
            num.value = n+1;
    }

    //实际只是增加了这部分


    </script>

     

     搜索:

    <dd>
           <strong>{$lang.number}:</strong>
            <input name="number" type="text" id="number" value="1" size="4" οnblur="changePrice()" style="border:1px solid #ccc; "/>
           </dd>

    修改成:

      <table>
              <tr>
                <td valign="middle" height="40" width="80" align="right"><font>{$lang.number}:</font> </td>
                <td valign="middle"><img src="images/jian.gif" style="display:block;" οnclick="del();changePrice()" /> </td>
                <td><input name="number" type="text" id="number" value="1" size="4" οnblur="changePrice()" style="border:1px solid #ccc; height:25px; width:30px; text-align:center; "/></td>
                <td><img src="images/jia.gif" style="display:block;" οnclick="add();changePrice()" /> </td>
              </tr>
            </table>

     

    将下面图片放到模板目录:(注意修改成你的图片路径)

      

     

    二.购物车页面

     

    打开:flow.dwt

    1、找到

    {* 包含脚本文件 *}
    {insert_scripts files='common.js,shopping_flow.js'}

    <!--增加下面脚本代码-->

    <script language="javascript" type="text/javascript">
                    function goods_cut($val){
                        var num_val=document.getElementById('number'+$val);
                        var new_num=num_val.value;
                        if(isNaN(new_num)){alert('请输入数字');return false}
                        var Num = parseInt(new_num);
                        if(Num>1)Num=Num-1;
                        num_val.value=Num;
                        document.getElementById('updatecart').click();
                    }
                    function goods_add($val){
                        var num_val=document.getElementById('number'+$val);
                        var new_num=num_val.value;
                        if(isNaN(new_num)){alert('请输入数字');return false}
                        var Num = parseInt(new_num);
                        Num=Num+1;
                        num_val.value=Num;
                        document.getElementById('updatecart').click();
                    }
                </script>

     

    2、搜索:

    <input type="text" name="goods_number[{$goods.rec_id}]" id="goods_number_{$goods.rec_id}" value="{$goods.goods_number}" size="4" class="inputBg" style="text-align:center " οnkeydοwn="showdiv(this)"/> 

    修改成:

    <span class="goods_cut" οnclick="goods_cut('{$goods.rec_id}');"></span>
    <input type="text" name="goods_number[{$goods.rec_id}]" id="number{$goods.rec_id}" value="{$goods.goods_number}" size="4" class="number" οnblur="if(isNaN(this.value)){alert('请输入数字');return false}else{document.getElementById('updatecart').click();}" title="{$lang.goods_number_tip}"/>
    <span class="goods_add" οnclick="goods_add('{$goods.rec_id}');"></span>

     

    3.搜索:

    <input name="submit" type="submit" class="bnt_blue_1" value="{$lang.update_cart}" /> 
    修改成: 

    <input name="submit" type="submit" id="updatecart" value="{$lang.update_cart}" class="btn_s3"/>

     

    打开:style.css文件,底部下面添加

    .goods_cut {
    background: url("images/yy.gif") no-repeat scroll 0 0 transparent;
    border: 0 none;
    cursor: pointer;
    display: block;
    float: left;
    font-size: 0;
    height: 15px;
    line-height: 0;margin: 8px 3px 0;
    width: 15px;
    }
    input.goodsBuyBox, input.number {
    border: 1px solid #DDDDDD;
    float: left;
    font-size: 10px;
    height: 18px;
    line-height: 18px;
    margin: 5px 6px 0;
    padding: 0;
    text-align: center;
    width: 32px;
    }
    .goods_add {
    background: url("images/yy.gif") no-repeat scroll 0 -15px transparent;
    border: 0 none;
    cursor: pointer;
    display: block;
    float: left;
    font-size: 0;
    height: 15px;
    line-height: 0;
    margin: 8px 3px 0;
    width: 15px;
    }
    .goods_number_tit{
    display: block;
    background:none;
    width:60px;
    height:25px;
    line-height:22px;
    float: left;
    }

    5.将下面图片放到模板目录:(注意修改成你的图片路径)

     

    新手使用的是默认模板可以直接覆盖下面附件:

    ecshop购物车加减插件下载:www.ecshop119.com/moban-318.html

    注: 原文的商品页的数量增加减少按钮没有添加价格改变的函数,如果查看原文的,在按钮上加上 changePrice() 

    如下:

    <table>
              <tr>
                <td valign="middle" height="40" width="80" align="right"><font class="shop">{$lang.number}:</font> </td>
                <td valign="middle"><img src="images/jian.gif" style="display:block;" οnclick="del();changePrice()" /> </td>
                <td><input name="number" type="text" id="number" value="1" size="4" οnblur="changePrice()" style="border:1px solid #ccc; height:25px; width:30px; text-align:center; "/></td>
                <td><img src="images/jia.gif" style="display:block;" οnclick="add();changePrice()" /> </td>
              </tr>
            </table>

     

    转载请注明:ECshop119模板屋-ECshop教程网(全国最专业的ECSHOP插件制作商-专业ECSHOP二次开发)

    转载于:https://www.cnblogs.com/zhicheng/p/4397649.html

    展开全文
  • 本文实例讲述了js简单实现表单中点击按钮动态增加输入框数量的方法。分享给大家供大家参考。具体如下: 这里演示表单中点击按钮动态增加输入框数量的方法,默认是没有输入框,点击按钮之后,输入框会不断的增加,每...
  • jquery按钮控制text文本框商品数量增加或减少,加了很多判断,记录一下 *{margin:0;padding:0;} a,img{border:0;text-decoration:none;} body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";} ...
  • 实现一个加减按钮,就简单的实现了一个带加减按钮的小功能 首先看下这个布局 ?xml version="1.0" encoding="utf-8"?> android:layout_width="90dp" android:layout
  • 带有增加与减少按钮数量选择控件 用法:  xmlns:app="http://schemas.android.com/apk/res-auto"  android:id="@+id/quantityView_default"  android:layout_width="wrap_content"  android:layout_height=...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 869
精华内容 347
关键字:

数量增加按钮