<input type="checkbox" value="1" name="check" checked="checked" />1
    <input type="checkbox" value="2" name="check" />2
    <input type="checkbox" value="3" name="check" checked="checked" />3前提是不提交的情况下,实时监听。
比如选择了1和3然后告诉用户已经2个,价格是50X2因为这里先计算价格 最后再把这个价格 存到数据库

解决方案 »

  1.   

    你在程序里面写var_dump($_POST); 看看结构,然后相信你就知道应该怎么做了,如果还不会,把结果贴到这里,有人告诉你怎么做的。
      

  2.   

    既然不提交表单,那就用js<form action ="" id ="form1" >
    <input type="checkbox" value="1" id="1" name="check" checked="checked" onchange="show()"/>1 
    <input type="checkbox" value="2" name="check" onchange="show()"/>2 
    <input type="checkbox" value="3" name="check" checked="checked" onchange="show()"/>3
    <input type="checkbox" value="4" name="check" checked="checked" onchange="show()"/>4
    <input type="checkbox" value="5" name="check" checked="checked" onchange="show()"/>5
    </form>
    <span id="show" color="red"></span>
    <script type="text/javascript">
        function show(){   
            objName = document.getElementById("form1");
            total = 0; 
            for (i=0; i<objName.length; i++){
               if (objName[i].type=="checkbox" && objName[i].checked){    
                    total++;            
                    }
            }
            document.getElementById('show').innerHTML = '你选择了'+total+'个商品,价格是'+total*50;
         }
    </script>
      

  3.   

    可是在PHP 怎么使用监听出来的数值的呢?
      

  4.   

    可是在PHP 怎么使用监听出来的数值的呢?
      

  5.   


    提交表单的值用php获取(POST),没有提交表单用js获取。