i have failed to validate if statement as shown in code below ,while i can get the value of "@Model.FreelancerProposals.Where(a => a.IsAssigned == true)"in html but cant validate if statement using the same value in javascript, what is your advice for this scenario.
<script>
if(@Model.FreelancerProposals.Where(a => a.IsAssigned == true).Count() > 0)
{
function addDays(date, days) {
var result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}
// Set the date we're counting down to
/**/
var countDownDate = new Date("@Model.FreelancerProposal.DateofRecord.Month, @Model.FreelancerProposal.DateofRecord.Day, @Model.FreelancerProposal.DateofRecord.Year @Model.FreelancerProposal.DateofRecord.Hour:@Model.FreelancerProposal.DateofRecord.Minute:@Model.FreelancerProposal.DateofRecord.Second").getTime();
countDownDate=addDays(countDownDate,@Model.FreelancerProposal.DaysRequired) /**/
// Update the count down every 1 second
var x = setInterval(function () {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = days + "يوم " + hours + "س "
+ minutes + "د " + seconds + "ث ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "إنتهى الوقت المدد";
}
}, 1000);
}
</script>
Aucun commentaire:
Enregistrer un commentaire