Ja okay, har godt nok løst mit tidligere problem. Nu er mit problem, at jeg vil fjerne det udvalgte produkt når tid er udløbet.
Her kommer noget kode:
aspx:
<asp:DataList ID="DataList1" runat="server" DataSourceID="ObjectDataSource1" OnItemDataBound="DataList1_ItemDataBound"
RepeatColumns="4" RepeatDirection="Horizontal" CellPadding="0" CellSpacing="1">
<ItemTemplate>
<div class="datalistStyle">
<div align="center">
<br />
<asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("Model") %>' Font-Bold="True"
Font-Size="12pt" ForeColor="#6699FF" />
<br />
<br />
<asp:Image ID="Image11" runat="server" ImageUrl='<%# Eval("Billede","~/ProductImages\\t__{0}") %>' />
<br />
<div id='<%# Eval("ProductID") %>' style="font-size: 16px; font-weight: bold; color: #FF0000;
font-style: italic;">
<script> RunTimer('<%# Eval("ProductID") %>', '<%# Eval("Timer") %>');</script>
</div>
</div>
<div style="margin-left: 15px;">
<asp:Label ID="Label2" runat="server" ForeColor="#666666" Text="Type:" Font-Size="12px"></asp:Label>
<asp:Label ID="VariantLabel" runat="server" Text="" Font-Size="12px" ForeColor="#1B1B1B" />
</div>
<div style="margin-left: 15px;">
<asp:Label ID="Label4" runat="server" ForeColor="Gray" Text="Color:" Font-Size="12px"></asp:Label>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("Color") %>' ForeColor="#333333"
Font-Size="12px" />
</div>
<div style="margin-left: 15px; padding-bottom: 5px;">
<asp:Label ID="Label1" runat="server" ForeColor="Gray" Text="Amount:" Font-Size="12px"></asp:Label>
<asp:Label ID="AntalLabel" runat="server" Text='<%# Eval("Antal") %>' ForeColor="#333333"
Font-Size="12px" />
</div>
<div align="center">
<cc2:ModalPopupExtender ID="mpeReview" runat="server" BackgroundCssClass="popupBackground"
CancelControlID="btnCancel" PopupControlID="pnlPostReview" TargetControlID="ImageButton1">
</cc2:ModalPopupExtender>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl=""
OnClick="ImageButton1_Click" />
<br />
</div>
</div>
</ItemTemplate>
</asp:DataList>
javascript :
var regdate = /(\d+)[\/|\-](\d+)[\/|\-](\d+)\s(\d+)\:(\d+)\:(\d+)/i;
function CDate2(p_date) {
var arr_date = regdate.exec(p_date);
var new_date = new Date(arr_date[3], arr_date[2] - 1, arr_date[1], arr_date[4], arr_date[5], arr_date[6]);
return new_date;
}
function FormatTime(p_seconds) {
p_seconds = Math.floor(p_seconds / 1000);
var d = Math.floor(p_seconds / 86400);
p_seconds -= (d * 86400);
var h = p_seconds % 86400;
h = Math.floor(h / 3600);
p_seconds -= h * 3600;
var m = p_seconds % 3600;
m = Math.floor(m / 60);
p_seconds -= (m * 60);
var s = p_seconds % 60;
return d + " d " + h + " t " + m + " min. " + s + " sek.";
}
function RunTimer(p_id, p_datetime) {
if (document.getElementById(p_id)) {
var rt = document.getElementById(p_id);
var now = new Date();
var then = CDate2(p_datetime);
if (now < then) {
rt.innerHTML = FormatTime(then - now);
setTimeout("RunTimer('" + p_id + "', '" + p_datetime + "')", 1000);
} else {
rt.innerHTML = "Tid udløbet";
}
}