Print all date interval of entire week for selected date

week_date_with_hours_of_selected_date

<script language=”javascript”>
///datetime code
var selected_date = “4/13/2015”;
var myDate = new Date(selected_date);
var seldate = myDate;
var seldate_new = myDate;
var dayno = parseInt( myDate.getDay() );
document.write(“<table cellpadding=3><tr><td colspan=’7′ style=’background-color: lightgray;’>Selected Date=”+selected_date+”</td></tr>”);
document.write(“<tr>”);
for( i =0; i<7; i++){
document.write(“<td>”);
seldate_new = new Date(selected_date);
if( i< dayno ){
seldate = new Date(seldate_new.setDate( myDate.getDate() – (dayno-i) ));
document.write(seldate);
}else if( i == dayno ){
seldate = new Date(seldate_new.setDate( myDate.getDate() ));
document.write(seldate);
}else{
seldate = new Date(seldate_new.setDate( myDate.getDate() + (i-dayno) ));
document.write(seldate);
}
var current_month = seldate.getMonth(); //months from 1-12
var current_day = seldate.getDate();
var current_year = seldate.getFullYear();

document.write(“<table border=1 width=’100%’>”);
//for hour slots
for( K =0; K<24; K++){
document.write(“<tr><td>”);
document.write(K+”-“+(parseInt(K)+1));
document.write(“<INPUT type=’radio’ name=’rdo_”+( “_” + (parseInt( current_month)+1) + “_” + current_day + “_” + current_year)+”‘ id=’rdo_”+( “_” + (parseInt( current_month)+1) + “_” + current_day + “_” + current_year + “_” + K)+”‘ value='”+K+”‘>”);
document.write(“</td></tr>”);

}
document.write(“</table>”);
document.write(“</td>”);
}
document.write(“</tr></table>”);
</script>

Tags: ,