topical media & game development

talk show tell print

basic-javascript-09-ch09-q2.htm / htm

  <script language="JavaScript" type="text/javascript">
  var days = new Array();
  days[0] = "Sunday";
  days[1] = "Monday";
  days[2] = "Tuesday";
  days[3] = "Wednesday";
  days[4] = "Thursday";
  days[5] = "Friday";
  days[6] = "Saturday";
  function dayOfWeek()
     var form = document.form1;
     var date = parseInt(form.txtDate.value)
     var year = parseInt(form.txtYear.value)
     if (isNaN(date) || isNaN(year))
        alert("Please enter a valid whole number");
        if (date < 1 || date > 31)
           alert("Day of the month must be between 1 and 31");
           userDate = date + " ";
           userDate = userDate + 
           userDate = userDate + " " + year;
           var dateThen = new Date(userDate);
  <P>Find the day of your birth</P>
  <form name="form1">
  <input type="text" name="txtDate" size="2" maxlength="2">
  <select name=selMonth>
     <option selected value="Jan">Jan</option>
     <option selected value="Feb">Feb</option>
     <option selected value="Mar">Mar</option>
     <option selected value="Apr">Apr</option>
     <option selected value="May">May</option>
     <option selected value="Jun">Jun</option>
     <option selected value="Jul">Jul</option>
     <option selected value="Aug">Aug</option>
     <option selected value="Sept">Sept</option>
     <option selected value="Oct">Oct</option>
     <option selected value="Nov">Nov</option>
     <option selected value="Dec">Dec</option>
  <input type=text name=txtYear size=4 maxlength=4>
  <input type="button" value="Day of the week" 
        onclick="dayOfWeek()" name="button1">

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.