gpt4 book ai didi

来自数据库的javascript倒数计时器新日期

转载 作者:行者123 更新时间:2023-11-30 06:02:00 25 4
gpt4 key购买 nike

<script type="text/javascript">
$(function() {
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
$('#countdown').countdown({ until: newYear, format: 'DHMS', layout:
'<div id="timer">' + '<hr />'+
'<div id="timer_days" class="timer_numbers">{dnn}</div>'+
'<div id="timer_hours" class="timer_numbers">{hnn}</div>'+
'<div id="timer_mins" class="timer_numbers">{mnn}</div>'+
'<div id="timer_seconds" class="timer_numbers">{snn}</div>'+
'<div id="timer_labels">'+
'<div id="timer_days_label" class="timer_labels">days</div>'+
'<div id="timer_hours_label" class="timer_labels">hours</div>'+
'<div id="timer_mins_label" class="timer_labels">mins</div>'+
'<div id="timer_seconds_label" class="timer_labels">secs</div>'+
'</div>'+
'</div>'
});
});
</script>

我正在使用此脚本在我的网页上显示倒数计时器...但不是 newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);我想从我的数据库中获取新日期...我该怎么做??

aspx代码

<asp:HiddenField runat="server" ID="HF" />后面的代码[日期是10\21\2011] `

If defaultJob = False Then
sql.SelectCommand.CommandText = "SELECT OfferHeader, OfferDesc, MarketPrice, OfferPrice, Discount, PayInAdv, PayLater, ImageURL, AdTags,EndTime FROM " & offerTable & " WHERE CustID = '" & custID & "' AND BusiID=" & busiID & " AND OfferID=" & offerID
Else
sql.SelectCommand.CommandText = "SELECT OfferHeader, OfferDesc, MarketPrice, OfferPrice, Discount, PayInAdv, PayLater, ImageURL, AdTags,EndTime FROM " & offerTable & " WHERE CustID = '" & custID & "' AND BusiID=" & busiID & " AND OfferID=" & offerID
End If

Try
con.Open()
sql.Fill(table)
con.Close()

With table.Rows(0)
LblOfferHeader.Text = Convert.ToString(.Item(0))
LblOfferDesc.Text = Convert.ToString(.Item(1))
LblMarketPrice.Text = Convert.ToString(.Item(2))
LblOfferPrice.Text = Convert.ToString(.Item(3))
LblDiscount.Text = Convert.ToString(.Item(4))
LblPayInAdv.Text = Convert.ToString(.Item(5))
LblPayLater.Text = Convert.ToString(.Item(6))
ImgOfferImage.ImageUrl = Convert.ToString(.Item(7))
HF.Value = Convert.ToString(.Item(9))
End With
Catch ex As Exception
'MsgBox(ex.Message)
Finally
sql.Dispose()
con.Close()
con.Dispose()
End Try`

来自数据库的日期是 10\21\2011,但计时器显示还剩 36 分钟....为什么?我做错了什么???

最佳答案

现在修改您的标记以包含隐藏元素

<input type="hidden" runat="server" id="hiddenDate" />

//伪代码

Page_Load()
{
hiddenDate.value = datereadfromDatabase;

}

现在你的脚本看起来像这样:

<script type="text/javascript">
$(function() {
var newYear = $('#<%=hiddenDate.ClientID%>').val();
$('#countdown').countdown({ until: newYear, format: 'DHMS', layout:
'<div id="timer">' + '<hr />'+
'<div id="timer_days" class="timer_numbers">{dnn}</div>'+
'<div id="timer_hours" class="timer_numbers">{hnn}</div>'+
'<div id="timer_mins" class="timer_numbers">{mnn}</div>'+
'<div id="timer_seconds" class="timer_numbers">{snn}</div>'+
'<div id="timer_labels">'+
'<div id="timer_days_label" class="timer_labels">days</div>'+
'<div id="timer_hours_label" class="timer_labels">hours</div>'+
'<div id="timer_mins_label" class="timer_labels">mins</div>'+
'<div id="timer_seconds_label" class="timer_labels">secs</div>'+
'</div>'+
'</div>'
});
});
</script>

关于来自数据库的javascript倒数计时器新日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7826705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com