Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1649 How can I show the next seven days in a drop down list?

You are here: irt.org | FAQ | JavaScript | Date | Q1649 [ previous next ]

Try:

<script language="JavaScript"><!--
var now = new Date();
now = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0); // midnight

var text = '<form><select>';
for (i=0; i<7; i++) {
   var theDay = new Date(now.getTime()+(i*24*60*60*1000));
   text += '\n<option> ' + theDay.getFullYear() + '/' + (theDay.getMonth()+1) + '/' + theDay.getDate();
}
text += '</select></form>';
document.write(text);
//--></script>

©2018 Martin Webb