Announcement

Collapse
No announcement yet.

Displaying delivery dates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Also you can replace
    Code:
    document.write(' ' + myDate.getDate() + ' ');
    with

    Code:
    var dayofmonth =  myDate.getDate();
    var datesuffix = 'th';
    if ( (dayofmonth < 10) || (dayofmonth > 20) ) suffix = ['th','st','nd','rd'][dayofmonth % 10];
    document.write(' ' + dayofmonth + suffix + ' ');
    to get 1st, 2nd, 3rd type days.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #17
      Thank you Norman, brick as ever.
      Originally posted by NormanRouxel
      Also you can replace
      Last modification implemented now, good idea!

      Originally posted by NormanRouxel
      Could you edit your post #14 above and use [ C O D E ] and [ / C O D E ] tags instead of the HTML Code ones as it's inserting unwanted breaks.
      Done that! (Not that I know the difference)

      Donna are you there? All sorted (apart from delivery services not operating at Xmas although we, of course, still do) - thanks for starting this thread.



      .
      Paul
      Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

      Using V10.2 with Norman's brilliantly simple TABBER.

      Comment


        #18
        Originally posted by pfb5
        Donna are you there?
        LOL that's way past my bed time!

        Wow! That's really brilliant, I wouldn't have even thought that logically! It looks great on the site Paul too. I think this sort of thing can only help those 'wavering' cutomers. Will def. be implementing on our two sites.

        Thanks all for all your help.

        Donna
        Donna

        Chief bunting supplier to Take That!

        Comment


          #19
          Originally posted by NormanRouxel
          Also you can replace

          Code:
          var dayofmonth =  myDate.getDate();
          var datesuffix = 'th';
          if ( (dayofmonth < 10) || (dayofmonth > 20) ) suffix = ['th','st','nd','rd'][dayofmonth % 10];
          document.write(' ' + dayofmonth + suffix + ' ');
          to get 1st, 2nd, 3rd type days.
          Just to say when I change the add on days to get my standard delivery times the suffix stops working and goes to undefined. I'm trying to work out where it is causing the problem but I'm not sure I fully understand this bit of the code yet. It is fine if I revert to the original code without the siffix it adds the right number of days on.

          D
          Donna

          Chief bunting supplier to Take That!

          Comment


            #20
            I got it working very quickly, without any errors, by simply copying Norman's code from his post and pasting it straight in to Act_ProductLine.html.

            Then when he added a bit, I did the same.

            But Norman did say that because I wrapped my code in the wrong tags, I had broken it, so here it is again:

            Code:
            <script type="text/javascript"> 
            <!--
            var myDate=new Date();
            if ( myDate.getHours() < 15 ) // less than 3pm
              {
              var daystodeliver = [2,1,1,1,1,3,2][myDate.getDay()];
              }
            else
              {
              var daystodeliver = [2,2,2,2,2,4,3][myDate.getDay()];
              }
            myDate.setDate(myDate.getDate()+daystodeliver);
            document.write(['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][myDate.getDay()]);
            var dayofmonth =  myDate.getDate();
            var datesuffix = 'th';
            if ( (dayofmonth < 10) || (dayofmonth > 20) ) suffix = ['th','st','nd','rd'][dayofmonth % 10];
            document.write(' ' + dayofmonth + suffix + ' ');
            document.write(['January','February','March','April','May','June','July','August','September','October','November','December'][myDate.getMonth()]);
            // -->
            </script>
            Note, this is for overnight/next working day delivery & cut-off at 3pm.

            (Have a look now (it's 2.30pm) and again after 3pm to see if it's changed!)



            .
            Paul
            Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

            Using V10.2 with Norman's brilliantly simple TABBER.

            Comment


              #21
              Hi Paul

              I can get your code to work, it's when I mess with it it all goes wrong!!!! LOL

              Our standard delivery isn't as quick as yours and our cut off is 1pm not 3. (we have express options in checkout). I have changed the 15 to 13 for 1pm and all is fine. The I change the add on days from your 1 or 2 to say 5 and it doesn't like it. However if I go back to the code before the suffix (i.e. the 'TH') etc it is fine with my delivery schedule. I assume it is something to do with the <10 >20 but I haven't quite worked it out yet! D
              Donna

              Chief bunting supplier to Take That!

              Comment


                #22
                Shouts: "NORMAAAAAN - HELLLLPPP!"
                Paul
                Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

                Using V10.2 with Norman's brilliantly simple TABBER.

                Comment


                  #23
                  LOL



                  I have gone back to your code and adding 1 day, 2 days, 3 days and even 4 days is fine, I still get the 'th'. Add 5 and it returns Monday 4underfined February. Originally I thought it was the move into Feb that had confused it but I does 1st 2nd and third ok so it must be something to do with the 'th' element of the code. But if you add 0 days to today you get a 'th' so it's fine. If you add more than 10 days it doesn't display any date but does get the day of the week right.

                  I'll keep playing but I don't really understand the bit of the code that puts the suffix on so I'm not really sure what to do.

                  D
                  Donna

                  Chief bunting supplier to Take That!

                  Comment


                    #24
                    Well at least you're having a go, as previously commended - I don't understand the first thing about it at all!

                    By the way I refreshed my page every few seconds from 2.59pm and watched the date change!

                    Now I'll try what you're doing - if we both get the same problem, we'll have to wait for Norman to get in from the beach.


                    .
                    Paul
                    Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

                    Using V10.2 with Norman's brilliantly simple TABBER.

                    Comment


                      #25
                      Hope he's in Turkey then!

                      I've found that undefined means this:
                      Javascript treats undefined as being equal to null. A variable that has not been defined at all or which has been defined but not yet given a value will be considered to have a value of null or undefined.
                      So assume that it doesn't understand 5th 6th etc. I can see what it seems to be doing but I don't fuuly understand the 10% section so I'm a little flumoxed!

                      D
                      Donna

                      Chief bunting supplier to Take That!

                      Comment


                        #26
                        Yup, does the same for me. Perhaps he's missed a bit out.

                        (Don't keep calling it 'my' code - I only latched on to YOUR thread, copied Norman's good work, & put it online! I cannot take any credit for it!)


                        P
                        Paul
                        Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

                        Using V10.2 with Norman's brilliantly simple TABBER.

                        Comment


                          #27
                          Was busy. Here now. It's a bug. Fixed!

                          Change
                          Code:
                          var datesuffix = 'th';
                          if ( (dayofmonth < 10) || (dayofmonth > 20) ) suffix = ['th','st','nd','rd'][dayofmonth % 10];
                          to
                          Change
                          Code:
                          suffix = ((dayofmonth < 10)||(dayofmonth > 20)) ? ['th','st','nd','rd','th','th','th','th','th','th'][dayofmonth % 10] : 'th';

                          Or here's the whole thing fixed:
                          Code:
                          <script type="text/javascript"> 
                          <!--
                          var myDate=new Date();
                          if ( myDate.getHours() < 15 ) // less than 3pm
                            {
                            var daystodeliver = [2,1,1,1,1,3,2][myDate.getDay()];
                            }
                          else
                            {
                            var daystodeliver = [2,2,2,2,2,4,3][myDate.getDay()];
                            }
                          myDate.setDate(myDate.getDate()+daystodeliver);
                          document.write(['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][myDate.getDay()]);
                          var dayofmonth =  myDate.getDate();
                          suffix = ((dayofmonth < 10)||(dayofmonth > 20)) ? ['th','st','nd','rd','th','th','th','th','th','th'][dayofmonth % 10] : 'th';
                          document.write(' ' + dayofmonth + suffix + ' ');
                          document.write(['January','February','March','April','May','June','July','August','September','October','November','December'][myDate.getMonth()]);
                          // -->
                          </script>
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #28
                            Originally posted by NormanRouxel
                            Was busy.
                            We quite understand!

                            But we knew you'd fix it.
                            Many thanks.
                            Paul
                            Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

                            Using V10.2 with Norman's brilliantly simple TABBER.

                            Comment


                              #29
                              Thanks Norman, you're a star I knew it had to be that line but I didn't know where to start to fix it Your help is much appreciated. KR D
                              Donna

                              Chief bunting supplier to Take That!

                              Comment


                                #30
                                It's so tricky to test. The output is dependent on the day of the month so it could break again tomorrow. I hope not, but I didn't have time to set my system clock to each day and run said code.
                                Norman - www.drillpine.biz
                                Edinburgh, U K / Bitez, Turkey

                                Comment

                                Working...
                                X