JS實現團購商品倒計時功能代碼

www.8779129.live 原創 歡迎轉載

在做商品限時購買,特別是團購方面,倒計時就派上用場啦,下面介紹一款簡單實用的倒計時代碼,通過純JS腳本實現。

 <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];
//倒計時結束OVER

专注投入 才能赚钱 重庆时时全天计划飞 海南4 1开奖结果 北京快3和值开奖结果 a股权重股 加拿大快8开奖有官网吗 海南七星彩app安卓版 十一选五一定牛走势图 p2p网贷理财平台哪个好式服务平台怎么样 湖北11选5任五走势图 国元证券股票