JuliaNell 0 Newbie Poster

Hi guys, can any one correct my coding please, I want to create a form which ask for a month(dropdown) and year on input and onsubmit it checks if fields are valued and if so submit a page with teh calender of that month. Saterdays and sundays should have different colors, plus the user can choose anotehr month in the page of the month chosen.. This is what I've tried on my own and i just need direction , thank u...

<html >
<head>
<title>Exercise1</title>
<script type="text/javascript" src="jquery/jquery/jquery.js">
<script type="text/javascript">
function valid()
{
	var field = "";
	if (!$('[name=month]').val()) field += 'month\n';
	if (!$('[name=year]').val()) field += 'year\n';
	
	if (field != "") {
		alert ('Please select the value\n'+field);
		return false;
	}
return true;
}

</script>
<?php
if (!checkdate($_POST[month], 1, $_POST[year])) {
       $calArray = getdate();
       $month = $calArray['mon'];
       $year = $calArray['year'];
   } else 
   {
       $month = $_POST[month];
       $year = $_POST[year];
 	}
 $start = mktime (12, 0, 0, $month, 1, $year);
 $firstDayArray = getdate($start);
 
 $months = Array("January", "February", "March", "April", "May",
 
  "June", "July", "August", "September", "October", "November", "December");
 

  for ($x=1; $x <= count($months); $x++) {

  	    print "\t<calender=\"$x\"";

  	       print ($x == $month)?" SELECTED":"";

  	          print ">".$months[$x-1]."\n";

  	     }
  for ($x=0; $x<=2010; $x++) {
   print "\t<calender";
   print ($x == $year)?" SELECTED":"";
   print ">$x\n";
 }
 ?>
<style>
</style>
</head>
<body>
<h3>Calender</h3>
<form method="post" name="form" action="exercise2.php" onsubmit="return valid()">
    <select name="month"><option value=""></option>
    <option value="1">January</option>
    <option value="2">February</option>
    <option value="3">March</option>
    <option value="4">April</option>
    <option value="5">May</option>
    <option value="6">June</option>
    <option value="7">July</option>
    <option value="8">August</option>
    <option value="9">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
    </select>
    Year
    <input type="text" name="year" size="4" value="">
	<input type="submit" value="Submit">
</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.