Jump to content

dgenxp

Members
  • Posts

    2
  • Joined

  • Last visited

dgenxp's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Ahh ok I get it, as per usual i'm over complicating things [FACEPALM] thanks for the help I was hoping there would be a way simular to this I think im on the right track now maybe me and javascript will get on after all, any other help would be appreciated but I think im good now
  2. Hi I am new to javascript and am wondering why this code does not return the value for which I need, Basically on the home page of a website I am developing there is a section that states when and where the next game is on the fixture. So what I am hoping to achieve is that this code will detect today's date and compare it with the next date in the Array that follows the current date, as an examplescan through the array of days, then compare this to the month if it is above today's date then the next game date is displayed along with the string that states the team that we are playing. when it hits the next date to stop checking until I reload the websitethe code that I wrote to support this is below, as I said I am new to javascript coding and if there is a better way then I will be more than happy to make the adjustments needed, I am not sure how to make an array of dates so I used a really botched version so i'm hoping that you guys can help me var Fixtures = ["The Raiders V Valley Cougars","The Raiders V Leicester Storm","The Raiders V Torfaen Tigers","The Raiders V Bristol Sonics","The Raiders V Gloucestershire Warriors","The Raiders V Sheffield Hallam Eagles","The Raiders V Nottingham Outlaws","The Raiders V Leicester Storm","The Raiders V Coventry Bears","The Raiders V Oxford Cavaliers" ];var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var months = ["January","February","March","April","May","June","July","August","September","October","November""December"];var NowDate = new Date(); var HomeGameDays = [21,9,16,20,27,18,25,8,22,5]; var HomeGameMonths =[2 ,4, 4, 5, 5, 6, 6,7, 7,8]; var DateComparer = new Date(); var NextGameDate = new Date(); var CaughtDate = false; var Fixture ="Awaiting";var Passed = "Pass"; for(i = 0; i < HomeGameMonths.length; i++) { if(NowDate.getMonth() <= HomeGameMonths[i]) { if(NowDate.getDate() <= HomeGameDays[i] && CaughtDate == false){Passed = "Confirmation" + i;DateComparer = Date(2015,HomeGameMonths[i],HomeGameDays[i]); Fixture = Fixtures[i];NextGameDate = Date(2015, HomeGameMonths[i], HomeGameDays[i]);CaughtDate = true;}}}var NextGame = "Next> " + DateComparer;document.getElementById("demo").innerHTML = Fixture+ "</br>"+NextGameDate;</script> Alot of this code has test elements in it just for my own debug purposes but the result that i get from this is Obviously this is completely wrong as it should state or something along those lines, instead it is completely ignoring the if statement and it is not adjusting the date at all, I am at a loss i have been programming for a long time now so this should be a simple piece of code but it has proven fruitless. I know there are other ways.. Better ways but as im new i used this method, if anybody can either tell me what is causing this problem or a better way to code it im all ears. Thanks in advance
×
×
  • Create New...