html5 - IF logic with HTML / JavaScript -


i trying figure out how code following logic in html.

  • if today's date wednesday sunday, text output should "1"
  • if today's date = monday, output = "2"
  • if today's date = tuesday, output = "3"

this how far got, once again stuck.

thank help!

<!doctype html> <html> <body>  <p id="dayofarrival"></p>  <script> function eta() {     var eta;     var day = dayofweek();     if (day = "monday") {         eta = "2";     } else if (day = "tuesday") {         eta = "3";     } else {         eta = "1";     } document.getelementbyid("dayofarrival").innerhtml = eta; }  function dayofweek() {     var d = new date();     var weekday = new array(7);     weekday[0] = "sunday";     weekday[1] = "monday";     weekday[2] = "tuesday";     weekday[3] = "wednesday";     weekday[4] = "thursday";     weekday[5] = "friday";     weekday[6] = "saturday";      var n = weekday[d.getday()];     document.getelementbyid("demo").innerhtml = n; } </script>  </body> </html> 

there's couple of ways of solving this.

first, can use client-side javascript. purposes, simplest approach.

secondly, use server-side code generates html apply logic on server final html desire. that, need in c#/mvc framework, php, or host of other solutions.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -