在foreach循环中的Javascript倒计时时钟

时间:2015-02-11 14:59:53

标签: javascript dynamic model-view-controller countdown countdowntimer

我想为图表的每一行显示实时倒计时时钟。 和@ solicitation.SolicitationResponseDeadLine是每一行的到期时间。 我可以显示倒计时,但仅显示第一行(重复ID)。请帮我。谢谢

<tbody>
    @foreach (var solicitation in Model)
    {
        <tr>
            <td scope="row">


                <a href="@string.Format(ConfigurationManager.AppSettings["FBOListingLink"], (string) ViewBag.CallingIC, solicitation.SolicitationNumber)" target="_blank">
                    @solicitation.SolicitationNumber
                </a>

            </td>
            <td>
                @solicitation.GetNoticeTypeName()
            </td>
            <td>
                @solicitation.SolicitationTitle
            </td>
            <td style="width: 15%;">
                @*@solicitation.eCPSUser_UserType.AppUser.AppUserFullName*@
                @solicitation.PrimaryAssociation.appUser.AppUserFullName
            </td>
            <td align="center" style="width: 15%;">
                @solicitation.SolicitationResponseDeadline
            </td>
            <td>
                <span style="display: block;">@solicitation.SolicitationResponseDeadline</span>
                <span class="#countDownCell"></span>

            </td>
        </tr>
    }

1 个答案:

答案 0 :(得分:-1)

     @{
                        var vYear = Convert.ToDateTime(solicitation.SolicitationResponseDeadline).Year;
                        var vMonth = Convert.ToDateTime(solicitation.SolicitationResponseDeadline).Month;
                        var vDay = Convert.ToDateTime(solicitation.SolicitationResponseDeadline).Day;
                        var vMinute = Convert.ToDateTime(solicitation.SolicitationResponseDeadline).Minute;
                        var vSecond = Convert.ToDateTime(solicitation.SolicitationResponseDeadline).Second;

                    }

                    <script type="text/javascript">
                        var note = "the winter is coming";
                        var nYear = [@vYear];
                        var nMonth = [@vMonth];
                        var nDay = [@vDay];
                        var nMinute = [@vMinute];
                        var nSecond = [@vSecond];
                        tdy = new Date(nYear, nMonth, nDay, nMinute, nSecond);

 $("#testCountDown").countdown({
            until: tdy,
            compact: true,
            description: ""
        });