Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 48

Thread: Birthday Script

  1. #31
    New Coder
    Join Date
    May 2005
    Location
    Los Angeles
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xxlxxl
    Glenn, i'd like to use the code you mentioned wrote in your second post, but using the DD/MM configuration and without displaying the year of birth, just day and month. Last thing, i'd like it to display the birthdays in the next 7 days.

    thanks, congrats
    yea! me too! If I type in the year, can I make it go away?
    "Last thing, i'd like it to display the birthdays in the next 7 days."
    Not hard to do, but not easy, I'd like it to do lots of things, Holy Hell!, Where do people like you come from? I know you understand the year is not shown in the format you have gushed over, but don't abuse your right to post here for help.
    Last edited by gmn17; 05-04-2006 at 07:00 AM.

  2. #32
    New Coder
    Join Date
    May 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ...using the DD/MM configuration...[and] display the birthdays in the next 7 days.
    I'm not sure this is exactly what you were looking for, but I thought it would be neat to make the mods. It works for me in firefox and IE.

    Code:
    <html>
    <head>
    <title>Birthday List</title>
    <script type="text/javascript">
    //the bday array data can be generated from server-side
    var arrBday = [
      ['Aunt B.', '5/6'],
      ['Goober', '5/7'],
      ['Andy', '5/8'],
      ['Otis', '5/9'],
      ['Earnest T.', '5/10'],
      ['Opey', '5/11'],
      ['Barney', '5/12'], 
      ['Thelma Lu', '5/13']
      //...and so on (last entry must not have a trailing comma)
    ];
    
    function getBdaysThisWeek(){
      var arrMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
      var bday, idx;
      var bdayList = new Array();
      var today = new Date();
    
      for (var i=0;i<arrBday.length;i++){
        var bday = new Date(arrBday[i][1] + '/' + today.getFullYear());
        if (isNaN(bday)) continue;
    
        if ( isBdayInRange(bday, 7) ){
           idx = bdayList.length;
           bdayList[idx] = new Object();
           bdayList[idx].name = arrBday[i][0];
           bdayList[idx].bday = bday;
           bdayList[idx].month = arrMonth[bday.getMonth()];      
        }
      }
      if (bdayList.length > 0){ //sort asc by birthdate
         bdayList.sort(
           function(a, b){
             if (a.bday < b.bday) return -1
             if (a.bday > b.bday) return 1;
             return 0;
           }
         );
      }
      return bdayList;
    }
    
    function isBdayInRange(bday, interval){
    //credit for this function goes to:
    //-Rob (@slingfive) Eberhardt, Slingshot Solutions
    //http://slingfive.com/pages/code/jsDate/jsDate.html
    
      var today = new Date(); 
      //have to override time so entire day will be valid
      today.setHours(0,0,0,0);
      //if the birthday has already occurred in the year, increment to the next year
      if (bday < today)
        bday.setFullYear(bday.getFullYear() + 1);
      
      // get ms between dates (UTC) and make into "difference" date
      var iDiffMS = bday.valueOf() - today.valueOf();
      //divide iDiffMS by 1000, Seconds, Minutes, Hours
      nDays = parseInt(iDiffMS / 1000 / 60 / 60 / 24);
      
      if(parseInt(nDays) <= parseInt(interval))
        return true;
      else
        return false;
    }
    
    function displayBdayList(){
      var date = new Date().getDate();	
      var bdayList = getBdaysThisWeek();
      var len = bdayList.length;
      var s = "<h1>Birthday Celebrants for this week:</h1>";
      if (len>0){
        s += '<ul>';
        for (var i=0; i<len; i++){
           //be mindful of the string-line continuation character (\) at the end of the first line
    		s += '<li' + ((date == bdayList[i].bday.getDate())?' class="bdayToday"':'')+ '>\
    					<strong>' + bdayList[i].name + '</strong> - ' 
    					+ bdayList[i].month + ' ' + bdayList[i].bday.getDate() + '</li>';       
        }
        s += '</ul>';
      }
      else{
        s += "No birthday celebrant for this week.";
      }
      document.write(s);
    }
    </script>
    <style type="text/css">
    body {
      font:14px Verdana;
    }
    /*display style when bday is today*/
    .bdayToday {
      color: red;
    }
    </style>
    </head>
    <body>
    <script type="text/javascript">
    displayBdayList();
    </script>
    </body>
    </html>

  3. #33
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks a lot, it wasn't really what I wanted, but i managed to make it work the way I wanted due to the way you wrote it because i don't know anything about scripts.

  4. #34
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can someone please help me make a change to this code because i am terrible at javascript!!

    i would like it to display the celebrant's age and also when their birthday is "today", i would like it to say "[name] celebrates their birthday today" and it can be red as it is.

    can someone plz help me?


    Code:
    <html>
    <head>
    <title>Birthday List</title>
    <script type="text/javascript">
    //the bday array data can be generated from server-side
    var arrBday = [
      ['Aunt B.', '5/6'],
      ['Goober', '5/7'],
      ['Andy', '5/8'],
      ['Otis', '5/9'],
      ['Earnest T.', '5/10'],
      ['Opey', '5/11'],
      ['Barney', '5/12'], 
      ['Thelma Lu', '5/13']
      //...and so on (last entry must not have a trailing comma)
    ];
    
    function getBdaysThisWeek(){
      var arrMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
      var bday, idx;
      var bdayList = new Array();
      var today = new Date();
    
      for (var i=0;i<arrBday.length;i++){
        var bday = new Date(arrBday[i][1] + '/' + today.getFullYear());
        if (isNaN(bday)) continue;
    
        if ( isBdayInRange(bday, 7) ){
           idx = bdayList.length;
           bdayList[idx] = new Object();
           bdayList[idx].name = arrBday[i][0];
           bdayList[idx].bday = bday;
           bdayList[idx].month = arrMonth[bday.getMonth()];      
        }
      }
      if (bdayList.length > 0){ //sort asc by birthdate
         bdayList.sort(
           function(a, b){
             if (a.bday < b.bday) return -1
             if (a.bday > b.bday) return 1;
             return 0;
           }
         );
      }
      return bdayList;
    }
    
    function isBdayInRange(bday, interval){
    //credit for this function goes to:
    //-Rob (@slingfive) Eberhardt, Slingshot Solutions
    //http://slingfive.com/pages/code/jsDate/jsDate.html
    
      var today = new Date(); 
      //have to override time so entire day will be valid
      today.setHours(0,0,0,0);
      //if the birthday has already occurred in the year, increment to the next year
      if (bday < today)
        bday.setFullYear(bday.getFullYear() + 1);
      
      // get ms between dates (UTC) and make into "difference" date
      var iDiffMS = bday.valueOf() - today.valueOf();
      //divide iDiffMS by 1000, Seconds, Minutes, Hours
      nDays = parseInt(iDiffMS / 1000 / 60 / 60 / 24);
      
      if(parseInt(nDays) <= parseInt(interval))
        return true;
      else
        return false;
    }
    
    function displayBdayList(){
      var date = new Date().getDate();    
      var bdayList = getBdaysThisWeek();
      var len = bdayList.length;
      var s = "<h1>Birthday Celebrants for this week:</h1>";
      if (len>0){
        s += '<ul>';
        for (var i=0; i<len; i++){
           //be mindful of the string-line continuation character (\) at the end of the first line
            s += '<li' + ((date == bdayList[i].bday.getDate())?' class="bdayToday"':'')+ '>\
                        <strong>' + bdayList[i].name + '</strong> - ' 
                        + bdayList[i].month + ' ' + bdayList[i].bday.getDate() + '</li>';       
        }
        s += '</ul>';
      }
      else{
        s += "No birthday celebrant for this week.";
      }
      document.write(s);
    }
    </script>
    <style type="text/css">
    body {
      font:14px Verdana;
    }
    /*display style when bday is today*/
    .bdayToday {
      color: red;
    }
    </style>
    </head>
    <body>
    <script type="text/javascript">
    displayBdayList();
    </script>
    </body>
    </html>

  5. #35
    New to the CF scene
    Join Date
    Jun 2006
    Location
    Chennai
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I want from excel sheet

    Hi Guys,

    I want the above code which will retrive Name,Date of birth, Email-id (when user click the name it will be redirected to outlook to send a mail) from an excel sheet. And also if the Birthday comes on sunday, it must shows that birthday list on saturday itself. Please give the code for it. Awaiting for the reply....

    MaheshKumar
    Last edited by xp_mahesh; 06-10-2006 at 08:14 AM.

  6. #36
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,
    I was searching in Google for a birthday script to use on my website and I came across this forum. I think I will be adding it to my list of forums that I visit regularly for it has so much of smart discussions that benefit me and my work.
    I wanted to have my website users , after they submit my website form to be taken to another little form that asks them to enter their birthday, name, and email.
    I wanted this data to be picked up by a script and on each person's birthday the script will send a customized bday and keep in touch card in an email to that person's email.

    Can anyone help me with that? My server accepts PHP and not ASP.

    I know a little about programming and I've worked with codes before. If anyone can help me I would appreciate it, maybe show me a site that has similar scripts to do this job.

    If anyone is interested in helping as a paid developer I have no objection just contact me to discuss the price we can go from there.

    Thanks
    Nad
    Last edited by nadweb; 06-19-2006 at 08:43 PM.

  7. #37
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I'm new to all of this

    I've got an existing Intranet set up at work. The guy that set it up is no longer here. It has a birthday list that shows birthdays for the next two weeks, and if today is someone's birthday, then it shows up in red. This works great for us. So well that I wanted to do the very same thing with everyone's employment anniversary. I tried copying the code for bday and replacing it with Ann for Anniversary, but it still displays the birthdays. Any idea how to essentially run two birthday lists at once? The birthday list does not show age, but on the Anniversary, I could put the year they started employment rather than year of birth so it would be displayed 'John Doe - August 28 - 5 years'.

    The code looks identical to what mensa_dropout and seanko posted a few posts up.

    I'm new to this web site design, java scripting etc. and any help would be much appreciated.


    Thank you, thank you, thank you!!!
    Last edited by bkg4him; 08-23-2006 at 06:52 PM.

  8. #38
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    A problem is that Seanko in his post on 05-20-2006 didn't have an option of showing the age of the one who is celebrating the birthday. The code doesn't contain any info of the year of birth either.

    So, if I have the script of 05-20-2006, what do I have to do to have the age of the birthday child be displayed?

    CSky
    Last edited by csky; 09-27-2006 at 04:03 PM.

  9. #39
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please help.

    I am a newbie here and I have been looking for birthday script for a long time but with no luck.

    What I want to do is have a script that will read a field from a flat file containing the peoples names and birtdays. If this script can also send an email that that person upon their birthday it would be perfect.

    Can some please help me with this.

    Thanks in advance.

  10. #40
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, what means with this line below?
    //the bday array data can be generated from server-side
    var arrBday = [

    Is it possible to save the javascript in post #7 in this thread to a js.file or a flat-file instead?

  11. #41
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hope someone can still help with this

    Hi there,

    I hope someone out there can still help with this script. I tried it and it worked perfectly as is. Then I started customizing it by changing it to "Happy Birthday to:" and taking out the age display. It still worked fine. Then I changed the names and put today's date to test it and it still worked fine.

    Then I copied the list entries so I could display more and that's when it stopped working. I cut and pasted the same list into it but it comes up blank now.

    Is there a limit to how many names/birthdays can be on the list? Is there a way I can get it to watch a list of about 150 names throughout the year?

    Thanks very much in advance.

  12. #42
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi glenngv

    Your script is great it is working very well, accept that it only will work in mozilla and not IE.

    i getting the following error:

    'arrBday[...].1' is empty or no object

    Code: 0

    here is your script:

    Code:
    Date.prototype.getDiff = function(date, interval){
      if (typeof date == "string"){
         date = new Date(date);
      }
      if (isNaN(date) || !(date instanceof Date)){
         return NaN; //invalid date passed
      }
      if (typeof interval == "undefined") interval = "ms"; //msec (default)
      var diff = this - date; //alert(this+' - '+date+" = "+diff)//diff in msec
      switch(interval.toLowerCase()){
        case "s": //sec
          diff = diff/1000; break;
        case "n": //min
          diff = diff/(1000*60); break;
        case "h": //hr
          diff = diff/(1000*60*60); break;
        case "d": //day
          diff = diff/(1000*60*60*24); break;
        case "m": //month
          diff = diff/(1000*60*60*24*30); break;
        case "y": //year
          diff = diff/(1000*60*60*24*365); break;
        default:
          ; //msec
      }
      return Math.floor(diff);
    }
     var arrBday =[
      ['name1', '7/22/1981', "http://wesite.com"],
      ['name2', '9/20/1983', "http://website.com"],
      ['name3', '11/9/1985', "http://website.com"],
      ['name4', '11/9/1985', "http://website.com"],
      ['name5', '12/7/1980', "http://website.com"],
      ['name6', '12/2/1980', "http://website.com"],
      ['name7', '10/10/1983', "http://website.com"],
      ['name8', '7/26/1986', "http://website.com"],
      ];
    
    function getBdayList(numDays){
      var bday,temp,idx,diff;
      var today = new Date();
      var bdayList = new Array();
      for (var i=0;i<arrBday.length;i++){
        bday = new Date(arrBday[i][1]);
        if (isNaN(bday)) continue;
        temp = new Date(today.getFullYear(), bday.getMonth(), bday.getDate(), 23, 59, 59, 999);
        diff = temp.getDiff(today, "d");
        if (diff >= 0 && diff <= numDays){
           idx = bdayList.length;
           bdayList[idx] = new Object();
           bdayList[idx].name = arrBday[i][0];
           bdayList[idx].bday = arrBday[i][1];
           bdayList[idx].age = today.getDiff(bday, "y");
           if (diff > 6) bdayList[idx].age = bdayList[idx].age + 1;
           bdayList[idx].today = (diff == 0) ? true : false;
           bdayList[idx].site = arrBday[i][2];
        }
      }
      return bdayList;
    }
    
    function displayBdayList(){
      var bdayList = getBdayList(14);
      var len = bdayList.length;
      var s1 = ""; //today's bday list
      var s2 = ""; //next 2 week's bday list
      if (len>0){
        for (var i=0; i<len; i++){
           if (bdayList[i].today){
              if (s1 != ""){
                 s1 = ', <a href="' + bdayList[i].site + '">' +  bdayList[i].name + ' (' + bdayList[i].age + ')</a>';
              }
              else{
                 s1 = '<span class="bdayToday">Today:</span> <a href="' + bdayList[i].site + '">' +  bdayList[i].name + ' (' + bdayList[i].age + ')</a>';
              }
           }
           else{
             if (s2 != ""){
                s2 = ', <a href="' + bdayList[i].site + '">' +  bdayList[i].name + ' (' + bdayList[i].age + ')</a>';
             }
             else{
                s2 = '<span class="bdayLater">Within 14 Days:</span> <a href="' + bdayList[i].site + '">' +  bdayList[i].name + ' (' + bdayList[i].age + ')</a>';
             }
           }
         }
      }
      else{
        s1 = '<span class="bdayLater">No Birthdays.</span>';
      }
      document.write('<div>' + s1 + '</div><div>' + s2 + '</div>');
    }
    thanks for helping me out if you can
    i will really appreciated it.

    best regards,

    Danman28

  13. #43
    New to the CF scene
    Join Date
    Aug 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'd really hate to open Old topics, however i am faced with a problem beyond my amature javascript intelegence.

    The follow code is working 100% on my website. (This is the code displayed by glenn)
    PHP Code:
    <script language="JavaScript">
    var 
    arrBday = [
    [
    'Cynthia','8-15-1986'],
    [
    'lacey','10-31-1981'],
    [
    'Fuse','2-13-1990'],
    [
    'Jack','7-27-1995'],
    [
    '♋The Crimson Demon♋','1-1-1988'],
    [
    'emma','7-31-1998'],
    [
    'test','2-2-1989'],
    [
    'Sam','7-14-1989'],
    [
    'Joe','10-29-1991'],
    [
    'Seto','9-27-1987'],
    [
    'Kayla','1-27-1993'],
    [
    'Zane','7-31-1992'],
    [
    'natasha','1-1-1982'],
    ];

    function 
    displayBdayList(today){
      var 
    bday,strList='';
      for (var 
    i=0;i<arrBday.length;i++){
        
    bday = new Date(arrBday[i][1]);
        if (!
    isNaN(bday) && bday.getMonth()==today.getMonth() && bday.getDate()==today.getDate()) 
        
    strList+=''+arrBday[i][0]+" ("+(today.getFullYear()-bday.getFullYear())+"), ";
      }
      if (
    strList==''strList='No birthday today, Maybe tomorrow.'
      
    document.write(""+strList)
    }

    displayBdayList(new Date());
    </script> 
    The problem however, is that whenever i attempt to place a profile Link to this situation, it causes an error. -- Therefore i am forced to ask for your help.

    If anyone can be of assistance in resolving this problem, it'll be greatly appreciated as this concern is bugging me a bit and a few of my other staff members.

  14. #44
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,928
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    From looking at it I would say the problem is the last comma in the array (after the Natasha item). Remove that and see what happens.

  15. Users who have thanked VIPStephan for this post:

    iLovePIE (08-01-2013)

  16. #45
    New to the CF scene
    Join Date
    Aug 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    From looking at it I would say the problem is the last comma in the array (after the Natasha item). Remove that and see what happens.
    Thanks for the comment mate, i managed to use another code provided in this thread and it's working. -- Although i must say that ironically, adding a last "," to the end of the script's arrBday line, doesn't really affect the way the script functions.


 
Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •