频道栏目
首页 > 程序开发 > web前端 > JavaScript > 正文
JS实现商品倒计时
2013-05-05 11:00:21           
收藏   我要投稿

[html]
<SCRIPT LANGUAGE="JavaScript"> 
    function fresh() { 
        var time1 = document.getElementById("timeD").value; 
        for (var i = 1; i <= 5; i++) { 
            var endtime = new Date(time1); 
            var nowtime = new Date(); 
            var leftsecond = parseInt((endtime.getTime() - nowtime.getTime()) / 1000); 
            d = parseInt(leftsecond / 3600 / 24); 
            h = parseInt((leftsecond / 3600) % 24); 
            m = parseInt((leftsecond / 60) % 60); 
            s = parseInt(leftsecond % 60); 
 
            //        document.getElementById("times").innerHTML=__h+"小时"+__m+"分"+__s+"秒"; 
            document.getElementById("times"+i.toString()).innerHTML = h + "小时" + m + "分" + s + "秒"; 
            if (leftsecond <= 0) { 
                A 
            } 
        } 
    } 
    fresh() 
    var sh; 
    sh = setInterval(fresh, 1000); 
</SCRIPT> 
 
 
           //实现商品倒计时开始 
            
            DataSet dataset = new DataSet(); 
            string connStr = ConfigurationManager.ConnectionStrings["sqlservercon"].ConnectionString; 
            using (SqlConnection conn = new SqlConnection(connStr)) 
            { 
                conn.Open(); 
                using (SqlCommand cmd = conn.CreateCommand()) 
                { 
                    cmd.CommandText = "Select * from T_buondTimeBuy"; 
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd); 
                    adapter.Fill(dataset); 
                } 
            } 
 
            DataTable table = dataset.Tables[0]; 
            for (int i = 0; i < table.Rows.Count; i++) 
            { 
                DataRow row = table.Rows[i]; 
                 time[i]= (row["time"]).ToString(); 
            } 
 
         
            timeD.Value = time[1]; 
 
            //实现商品倒计时结束 

<SCRIPT LANGUAGE="JavaScript">
    function fresh() {
        var time1 = document.getElementById("timeD").value;
        for (var i = 1; i <= 5; i++) {
            var endtime = new Date(time1);
            var nowtime = new Date();
            var leftsecond = parseInt((endtime.getTime() - nowtime.getTime()) / 1000);
            d = parseInt(leftsecond / 3600 / 24);
            h = parseInt((leftsecond / 3600) % 24);
            m = parseInt((leftsecond / 60) % 60);
            s = parseInt(leftsecond % 60);

            //        document.getElementById("times").innerHTML=__h+"小时"+__m+"分"+__s+"秒";
            document.getElementById("times"+i.toString()).innerHTML = h + "小时" + m + "分" + s + "秒";
            if (leftsecond <= 0) {
                A
            }
        }
    }
    fresh()
    var sh;
    sh = setInterval(fresh, 1000);
</SCRIPT>


           //实现商品倒计时开始
          
            DataSet dataset = new DataSet();
            string connStr = ConfigurationManager.ConnectionStrings["sqlservercon"].ConnectionString;
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "Select * from T_buondTimeBuy";
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    adapter.Fill(dataset);
                }
            }

            DataTable table = dataset.Tables[0];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow row = table.Rows[i];
                 time[i]= (row["time"]).ToString();
            }

       
            timeD.Value = time[1];

            //实现商品倒计时结束

 

 

点击复制链接 与好友分享!回本站首页
相关TAG标签 商品
上一篇:Extjs4快速上手四——实现菜单
下一篇:winform调用javascript
相关文章
图文推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站