TinyPortal

Development => Block Codes => Topic started by: alan s on July 06, 2006, 02:42:28 PM

Title: What day were you born on
Post by: alan s on July 06, 2006, 02:42:28 PM
Came accross this script on some site and i edited it a bit to make it work better with tinyportal , it bascially asks for your date of birth and then tells you the day you were born , neat little script in my opinion , Just to make it clear to people what to do set up a html/javascript block and copy this code into it

<script LANGUAGE="JavaScript">
<!--edited by Alan S--!>
<!-- begin script

//General Array Function
function MakeArray(n) {
   this.length = n;
   for (var i = 1; i <=n; i++) {
     this[i] = 0;
   }
}

//Initialize Days of Week Array
days = new MakeArray(7);
days[0] = "Saturday"
days[1] = "Sunday"
days[2] = "Monday"
days[3] = "Tuesday"
days[4] = "Wednesday"
days[5] = "Thursday"
days[6] = "Friday"

//Initialize Months Array
months = new MakeArray(12);
months[1] = "January"
months[2] = "February"
months[3] = "March"
months[4] = "April"
months[5] = "May"
months[6] = "June"
months[7] = "July"
months[8] = "August"
months[9] = "September"
months[10] = "October"
months[11] = "November"
months[12] = "December"

//Day of Week Function
function compute(form) {
   var val1 = parseInt(form.day.value, 10)
   if ((val1 < 0) || (val1 > 31)) {
      alert("Day is out of range")
   }
   var val2 = parseInt(form.month.value, 10)
   if ((val2 < 0) || (val2 > 12)) {
      alert("Month is out of range")
   } 
   var val2x = parseInt(form.month.value, 10)
   var val3 = parseInt(form.year.value, 10)
   if (val3 < 1900) {
      alert("You're that old!")
   }
   if (val2 == 1) {
      val2x = 13;
      val3 = val3-1
   }
   if (val2 == 2) {
      val2x = 14;
      val3 = val3-1
   }
   var val4 = parseInt(((val2x+1)*3)/5, 10)
   var val5 = parseInt(val3/4, 10)
   var val6 = parseInt(val3/100, 10)
   var val7 = parseInt(val3/400, 10)
   var val8 = val1+(val2x*2)+val4+val3+val5-val6+val7+2
   var val9 = parseInt(val8/7, 10)
   var val0 = val8-(val9*7)
   form.result1.value = months[val2]+" "+form.day.value +", "+form.year.value
   form.result2.value = days[val0]
}   

// end script -->
</script>

<p>Enter B/d</b> (then hit the "Update" button):</p>

<form>
  <p>Month (1-12): <input TYPE="text" NAME="month" SIZE="2"> </p>
  <p>Date (1-31): <input TYPE="text" NAME="day" SIZE="2"> </p>
  <p>Year (eg. 1960): <input TYPE="text" NAME="year" SIZE="4"> </p>
  <p><input TYPE="button" VALUE="Update" ONCLICK="compute(this.form)"> <input TYPE="reset"
  VALUE="Clear"> </p>
  <p>DOB: <input TYPE="text" NAME="result1" SIZE="18"> </p>
  <p>Day of Week: <input TYPE="text" NAME="result2" SIZE="18"> </p>
</form>



Screen :(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.theteenzone.net%2FDOB.gif&hash=73babb316f67ad568cb4501257127c1734270d6c)

Live Demo : http://theteenzone.net/forum

Tested With : Internet Explorer , Opera And FireFox

 

Title: Re: What day were you born on
Post by: RoarinRow on July 06, 2006, 02:56:19 PM
Works good!   :up:
Title: Re: What day were you born on
Post by: IchBin on July 06, 2006, 03:13:32 PM
Was born on Thursday at 1:38 AM. I already new that, but nice script! :)
Title: Re: What day were you born on
Post by: alan s on July 06, 2006, 03:15:17 PM
i was born on thursday at 5 :05 pm i didnt know the day though..........
Title: Re: What day were you born on
Post by: Nokonium on July 06, 2006, 05:34:21 PM
Without checking I'd guess I was  Friday afternoon child  ;)
Title: Re: What day were you born on
Post by: IchBin on July 06, 2006, 05:48:43 PM
Wishful thinking Noko. ;)
Title: Re: What day were you born on
Post by: THUNDERxRAGE on September 05, 2007, 09:43:51 PM
I'm gonna try this.  I wish the screen shot and the forum was still there.
Title: Re: What day were you born on
Post by: jdvarner on September 06, 2007, 01:41:18 AM
i got it on lower right bottom of jdworld.net if ya wanna see it in action.