How can I alter these into PHP codes?


#1


<Doctype html>
<html>
<body>
<p>Please input the month using an integer (e.g. 1 for January and 12 for December):</p>

<input id="month"/>
<p>Please input the year (e.g. 2012):</p>
<input id="year"/><br><br>
<button onclick="calendarFunction()"> CLICK HERE </button>

<p id="result"> </p>

<script>
	function calendarFunction()
	{
		var month, year, days;
		
		month = parseInt(document.getElementById("month").value);
		year = document.getElementById("year").value;
		
		switch(month){
		case 1:
			month = "January";
			days = 31;
			break;
		case 2:
			if(year%4==0){
				document.getElementById("result").innerHTML = "February "+year+ " has 29 days.";
				break;
				}
			else{
				document.getElementById("result").innerHTML = "February "+year+ " has 28 days.";
				break;
				}
		case 3:
			document.getElementById("result").innerHTML = "March "+year+ " has 31 days.";
			break;
		case 4:
			document.getElementById("result").innerHTML = "April "+year+ " has 30 days.";
			break;
		case 5:
			document.getElementById("result").innerHTML = "May "+year+ " has 31 days.";
			break;
		case 6:
			document.getElementById("result").innerHTML = "June "+year+ " has 30 days.";
			break;
		case 7:
			document.getElementById("result").innerHTML = "July "+year+ " has 31 days.";
			break;
		case 8:
			document.getElementById("result").innerHTML = "August "+year+ " has 31 days.";
			break;
		case 9:
			document.getElementById("result").innerHTML = "September "+year+ " has 30 days.";
			break;
		case 10:
			document.getElementById("result").innerHTML = "October "+year+ " has 31 days.";
			break;
		case 11:
			document.getElementById("result").innerHTML = "November "+year+ " has 30 days.";
			break;
		case 12:
			document.getElementById("result").innerHTML = "December "+year+ " has 31 days.";
			break;
		default:
			document.getElementById("result").innerHTML = "Invalid Month";
		}
		document.getElementById("result").innerHTML = month + year + " has "+ days;
	}
</script>

</body>
</html>


CODE 2 




<Doctype html>

<html>

<body>

<p>Please input the month using an interger (e.g. 1 for January and 12 for December):</p>



<input id="month"/>

<p>Please input the year (e.g. 2012):</p>

<input id="year"/><br><br>

<button onclick="calanderFunction()"> CLICK HERE </button>



<p id="result"> </p>



<script>

function calanderFunction()

{

var month, year;



month = document.getElementById("month").value;

year = document.getElementById("year").value;



if(month==1)

document.getElementById("result").innerHTML = "January "+year+" has 31 days.";

else if(month==2){

if(year%4==0)

document.getElementById("result").innerHTML = "February "+year+ " has 29 days.";

else

document.getElementById("result").innerHTML = "February "+year+ " has 28 days.";

}

else if(month==3)

document.getElementById("result").innerHTML = "March "+year+ " has 31 days.";

else if(month==4)

document.getElementById("result").innerHTML = "April "+year+ " has 30 days.";

else if(month==5)

document.getElementById("result").innerHTML = "May "+year+ " has 31 days.";

else if(month==6)

document.getElementById("result").innerHTML = "June "+year+ " has 30 days.";

else if(month==7)

document.getElementById("result").innerHTML = "July "+year+ " has 31 days.";

else if(month==8)

document.getElementById("result").innerHTML = "August "+year+ " has 31 days.";

else if(month==9)

document.getElementById("result").innerHTML = "September "+year+ " has 30 days.";

else if(month==10)

document.getElementById("result").innerHTML = "October "+year+ " has 31 days.";

else if(month==11)

document.getElementById("result").innerHTML = "November "+year+ " has 30 days.";

else if(month==12)

document.getElementById("result").innerHTML = "December "+year+ " has 31 days.";

else

document.getElementById("result").innerHTML = "Invalid Month";

}

</script>



</body>

</html>


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.