Create a html page which has 3 drop downs listing Year,Month and dates respectively.
Upon select change event of date dropdown call a java scriptfunction which calculates the day and displays on a label.
<html>
<head>
<script type=”text/javascript” language=”javascript”>
var dys=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
function displayDay()
{
try
{
var yr=document.getElementById("slt_Years").value;
var mnt=document.getElementById("slt_Months").value;
var dt=document.getElementById("slt_Dates").value;
if(yr=='' || mnt=='' || dt=='' || yr==0 || mnt==0 || dt==0)
{
document.getElementById("lbl_Day").innerText='';
return;
}
var fdate=new Date();
fdate.setFullYear(yr);
fdate.setMonth(parseInt(mnt)-1);
fdate.setDate(dt);
document.getElementById("lbl_Day").innerText=dys[fdate.getDay()];
}
catch(e)
{
throw e;
}
}
</script>
</head>
<body>
<table>
<tr>
<td ><select id="slt_Years"></select>
<select id="slt_Months"></select>
<select id="slt_Dates"></select>
<br /><label id="lbl_Day" style="font-weight:bold; color:Maroon"></label>
</td>
</tr>
</table>
</body>
</html>
Output:
No comments:
Post a Comment