javascript - How to add another variable to a script -


i've having trouble trying following script work correctly. i'm trying add variable script, i've kind of hacked lack of programming knowledge! doesn't seem work when add variable called extradate. works without must getting wrong somewhere.

could please point out problem is?

thanks help.

output: using span id="extradate", id="fromdate" , id="todate"

script: //cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js

full code

var fromdate = date.today().adddays(1);         if (fromdate.is().saturday() || fromdate.is().sunday()) {            fromdate = fromdate.next().monday();         }         var todate = date.today().adddays(2);         if (todate.is().saturday()) {            todate = todate.next().monday();         }         else if (todate.is().monday()) {            todate = todate.next().tuesday();         }         else if (todate.is().sunday()) {            todate = todate.next().tuesday();         }         var extradate = date.today().adddays(4);         if (extradate.is().saturday() || extradate.is().sunday()) {            extradate = extradate.next().monday();         }         document.getelementbyid('fromdate').innerhtml = fromdate.tostring('dddd ds mmmm');         document.getelementbyid('todate').innerhtml = todate.tostring('dddd ds mmmm');         document.getelementbyid('extradate').innerhtml = extradate.tostring('dddd ds mmmm'); 

there has wrong html-code, because in example snippet exact code works without issues:

var fromdate = date.today().adddays(1);  if (fromdate.is().saturday() || fromdate.is().sunday()) {     fromdate = fromdate.next().monday();  }  var todate = date.today().adddays(2);  if (todate.is().saturday()) {     todate = todate.next().monday();  }  else if (todate.is().monday()) {     todate = todate.next().tuesday();  }  else if (todate.is().sunday()) {     todate = todate.next().tuesday();  }  var extradate = date.today().adddays(4);  if (extradate.is().saturday() || extradate.is().sunday()) {     extradate = extradate.next().monday();  }  document.getelementbyid('fromdate').innerhtml = fromdate.tostring('dddd ds mmmm');  document.getelementbyid('todate').innerhtml = todate.tostring('dddd ds mmmm');  document.getelementbyid('extradate').innerhtml = extradate.tostring('dddd ds mmmm');
<script src="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/datejs/date.js"></script>  <p id="fromdate"></p>  <p id="todate"></p>  <p id="extradate"></p>


Comments

Popular posts from this blog

java - AEM: 403 Forbidden occurs when call a Post servlet -

ruby on rails - ActiveRecord order not working -

Google Alert - facebook