+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    JavaScriptBank.com is offline Junior Member
    Join Date
    Mar 2009
    Location
    JavaScriptBank.com - Free JavaScript Source Code
    Posts
    44

    Born Which Day script

    I'm sure most of you are curious about what day of the week you were born. This script will tell you exactly that - in a nice layout, as well. Now, you know....

    Demo: hxxp://javascriptbank.com/born-which-day-script.html/en/

    Step 1: Place JavaScript below in your HEAD section
    JavaScript
    Code:
    <SCRIPT language=JavaScript>
    <!--
    function cala_day(form) {
            
            var nSwitch = 0
            var nMonth = parseInt(form.month.value)
            var nDay =  parseInt(form.day.value)
            var nYear =  parseInt(form.year.value)
            
            if(!(nYear % 4) && (nMonth > 2)) {
                    nSwitch = 1
            }               
    
            var nDayOfWeek = cala_weekday(nMonth, nDay, nYear)
            
            if(nSwitch) {
                    nDayOfWeek++
                    nSwitch = 0
            }
            
            day_display(form, nDayOfWeek)
    }
    
    function cala_weekday( x_nMonth, x_nDay, x_nYear) {
    
            if(x_nMonth >= 3){      
                    x_nMonth -= 2
            }
            else {
                    x_nMonth += 10
            }
    
            if( (x_nMonth == 11) || (x_nMonth == 12) ){
                    x_nYear--
            }
    
            var nCentNum = parseInt(x_nYear / 100)
            var nDYearNum = x_nYear % 100
            
            var nPart1 = parseInt(2.6 * x_nMonth - .2)
            
            var nZeller = (parseInt(nPart1 + x_nDay + nDYearNum + (nDYearNum / 4) + (nCentNum / 4) - 2 * nCentNum)) % 7
            
            if(nZeller < 0){
                    nZeller += 7
            }
            
            return nZeller
    }
    
    function day_display(form, x_nDayOfWeek) {
    
            if(x_nDayOfWeek == 0) {
                    form.birthday.value = "Saturday"
                    return
            }
            if(x_nDayOfWeek == 1) {
                    form.birthday.value = "Sunday"
                    return
            }
            if(x_nDayOfWeek == 2) {
                    form.birthday.value = "Monday"
                    return
            }
            if(x_nDayOfWeek == 3) {
                    form.birthday.value = "Tuesday"
                    return
            }
            if(x_nDayOfWeek == 4) {
                    form.birthday.value = "Wednesday"
                    return
            }
            if(x_nDayOfWeek == 5) {
                    form.birthday.value = "Thursday"
                    return
            }
            if(x_nDayOfWeek == 6) {
                    form.birthday.value = "Friday"
                    return
            }
    
            form.birthday.value = "Not a valid date."
    }
    //-->
    
    </SCRIPT>
    Step 2: Copy & Paste HTML code below in your BODY section
    HTML
    Code:
    <TABLE border=0 cellPadding=5 cellSpacing=5 width="96%">
      <TBODY>
      <TR>
        <TD width="100%">
          <FORM>
          <DIV align=center>
          <CENTER>
          <TABLE align=center border=1 width=225>
    
            <TBODY>
            <TR>
              <TD align=middle bgColor=#0000ff colSpan=2 width=250><FONT 
                color=#ffffff face=ARIEL,HELVETICA size=-1><B>When were you born?</B></FONT><FONT face=ARIEL,HELVETICA size=-1></FONT></TD></TR>
            <TR>
              <TD bgColor=#ff0000 width=100><FONT size=2><B><FONT 
                color=#ffff00>Month:</FONT></B><INPUT name=month 
                size=4><BR><BR><B><FONT color=#ffff00>Date:</FONT></B><INPUT 
                name=day size=4><BR><BR><B><FONT color=#ffff00>Year:</FONT></B><INPUT 
                name=year size=4></FONT> </TD>
              <TD align=middle bgColor=#ff0000 width=125><FONT 
                color=#ffff00><BR><FONT size=2><B>Ex:</B></FONT> <BR><FONT 
                size=2><I><B>07-06-1986</B><BR><B>Sunday</B></I><BR><BR><B>You were born:</B></FONT> <BR><INPUT name=birthday size=10> </FONT></TD></TR>
    
            <TR>
              <TD align=middle bgColor=#0000ff colSpan=2><INPUT onclick=cala_day(this.form) type=button value=OK><INPUT type=reset value=Reset></FONT></TD></TR></TBODY></TABLE></CENTER></DIV></FORM></TD></TR></TBODY></TABLE>
    hxxp://javascriptbank.com
    Last edited by JavaScriptBank.com; 08-26-2009 at 12:43 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Untitled Document
YoungEntrepreneur Logo Featured on: Business Week About Alltop Wall Street Journal

Terms of Service | Privacy Policy


SEO by vBSEO 3.5.0 RC3