既然是修改,为什么不直接前台修改完了,最后再提交服务器保存呢?如果一定要实时更新数据库,那就用AJAX吧

解决方案 »

  1.   

    以下写的是每秒跳转一次 你试试 我也是初学者
    function updateMe(url) {
    var quantity= document.getElementById("quantity").innerHTML;
    if(quantity > 0) {
    quantity--;
    document.getElementById("quantity ").innerHTML = delay;
    } else {
    window.top.location.href = url;
    }
        setTimeout("updateMe('" + url + "')", 1000);
    }
    然后在<script>标签中调用这个函数。
      

  2.   

    这个问题我觉得要用键或者集合去做。hashmap
    以下是我用HashMap做的一些代码,不完全。但估计你可以得到提示:比较简单。脚本代码。
    <body>
        <%
             String username=(String)session.getAttribute("username");
          HashMap<Integer,Integer> mapCar=(HashMap)session.getAttribute(username);
          if(mapCar==null)
            mapCar=new HashMap<Integer,Integer>();
      
          String prices[]=request.getParameterValues("price");
          String counts[]=request.getParameterValues("count");
          String names[]=request.getParameterValues("name");
          for(int i=0;i<names.length;i++)
          {
             names[i]=new String(names[i].getBytes("ISO8859-1"),"gb2312");
          }
          int totalPrice=0;
          int sum=0;
          for(int i=0;i<counts.length;i++)
          {
            if(!counts[i].equals(""))
            {
              int count=Integer.parseInt(counts[i]);
              int price=Integer.parseInt(prices[i]);
              int unit=count*price;
              totalPrice+=unit;
              mapCar.put(i,i);
              session.setAttribute(username,mapCar);
            }
            for(int j=0;j<counts.length;j++)
            {
               if(names[i]==names[j])
               {
                 
               }
            }
          }
     %>
      

  3.   

    IE6没问题的:<script type="text/javascript"> 
    function updateMe(){ 
    var quantity=document.getElementById('quantity').value; 
    alert(quantity); 

    </script> 
    <input type="text" name="txtquantity" value="3" size="1" id="quantity"> 
    [ <a href="javascript:updateMe()">修改 </a>]