You are here: irt.org | FAQ | JavaScript | Date | Q1493 [ previous next ]
Try:
<form> <script> now = new Date() aDay = 24*60*60*1000; then = new Date(now.getTime()-(14*aDay)); text = '<select>'; for (i=then.getTime();i<now.getTime();i+=aDay) { date = new Date(i); year = date.getYear(); if (year < 1900) year += 1900; dateString = (date.getMonth()+1)+'/'+date.getDate()+'/'+year; text += '\n<option value="' + dateString + '">'+ dateString+'</option>'; } text += '</select>'; document.write(text); </script> </form>