Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Website (Day checker)

  1. #1
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Website (Day checker)

    Hi, it has been many years since i have done any coding at uni, trying to make something for work where it checks the day and time and then dispalys text depending on that on the webpage. i could be no where near the right thing i have no idea

    <strong class="GeneratedText">
        <script type="text/javascript">
            document.write("<p>");
            var day = new Date();
            var weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
            var d = weekday[day.getDay()];
            var hr = day.getHours();
            if      ( d == "Monday" || d == "Tuesday" || d == "Wednesday" || d == "Thursday")) {
                document.write("Order By 1pm, We Can Deliver Tomorrow!");
           }    else if (((hr == 13) || (hr == 23)) &&
                ( d == "Thursday")) {
                document.write(" Order By 1pm Friday, We Can Deliver Monday!");
            }      else if (((hr == 00) || (hr == 12)) &&
                ( d == "Friday")) {
                document.write(" Order By 1pm Friday, We Can Deliver Monday!");
           }      else if (((hr == 13) || (hr == 23)) &&
                ( d == "Friday")) {
                document.write(" Order By 1pm Monday, We Can Deliver Tuesday!"); }
                  else if ( d == "Saturday" || d == "Sunday")) {
                document.write("Order By 1pm Monday, We Can Deliver Tuesday!"); }
     
     
            document.write("</p>");
        </script>
    </strong>
    Last edited by panda00; May 1st, 2019 at 03:23 AM. Reason: code fields

  2. #2
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Website (Day checker)

    made a few changes its now showing no errors but not displaying anything almost like its skipping over all the IF statements

    <strong class="GeneratedText">
        <script type="text/javascript">
            document.write("<p>");
            var day = new Date();
            var weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
              var d = weekday[day.getDay()];
            var hr = day.getHours();
            if      (( d == "Monday") && (hr == 00) || (hr == 12)) {
                document.write("Order By 1pm, We Can Deliver Tomorrow!"); }    
    	else if (( d == "Monday") && (hr == 13) || (hr == 23)) {
                document.write(" Order By 1pm Tomorrow, We Can Deliver Wednesday!"); }    	
    	else if (( d == "Tuesday") && (hr == 00) || (hr == 12)) {
                document.write("Order By 1pm, We Can Deliver Tomorrow!"); }    
    	else if (( d == "Tuesday") && (hr == 13) || (hr == 23)) {
                document.write(" Order By 1pm Tomorrow, We Can Deliver Thursday!"); }    
    	else if (( d == "Wednesday") && (hr == 00) || (hr == 12)) {
                document.write("Order By 1pm, We Can Deliver Tomorrow!"); }    
    	else if (( d == "Wednesday") && (hr == 13) || (hr == 23)) {
                document.write(" Order By 1pm Tomorrow, We Can Deliver Friday!"); }    
    	else if (( d == "Thursday") && (hr == 00) || (hr == 12)) {
                document.write(" Order By 1pm, We Can Deliver Tomorrow!");}    
    	else if (( d == "Thursday") && (hr == 13) || (hr == 23)) {
                document.write(" Order By 1pm Friday, We Can Deliver Monday!"); }      
    	else if (( d == "Friday") && (hr == 00) || (hr == 12)) {
                document.write(" Order By 1pm, We Can Deliver Monday!"); }      
    	else if (( d == "Friday") && (hr == 13) || (hr == 23)) {
                document.write(" Order By 1pm Monday, We Can Deliver Tuesday!"); }
            else if (( d == "Saturday" || d == "Sunday")) {
                document.write("Order By 1pm Monday, We Can Deliver Tuesday!"); }
     
     
            document.write("</p>");
        </script>
    </strong>

  3. #3
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Website (Day checker)

    check what is value d and hr. Does they matched the if and else-if condition?
    Whatever you are, be a good one

Similar Threads

  1. I want to convert sloane1.com (php website) to Java Website
    By jamespatrick in forum Web Frameworks
    Replies: 3
    Last Post: July 8th, 2014, 05:40 PM
  2. I want to convert sloane1.com (php website) to Java Website
    By jamespatrick in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 8th, 2014, 02:53 PM
  3. proxy checker keeps freezing
    By bean in forum What's Wrong With My Code?
    Replies: 13
    Last Post: June 3rd, 2013, 02:45 PM
  4. [SOLVED] Checker Program
    By maxreed in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 14th, 2012, 05:58 PM
  5. Magic Square Checker
    By Hypnos in forum Object Oriented Programming
    Replies: 1
    Last Post: April 3rd, 2011, 06:37 PM