You are here: irt.org | FAQ | JavaScript | Form | 3.3 | Q750 [ previous next ]
Try:
<SCRIPT LANGUAGE="JavaScript"><!-- function padout(number) { return (number < 10) ? '0' + number : number; } var today = new Date() var ftoday = padout(today.getDate()) + '/' + padout((today.getMonth() + 1)) + '/' + today.getYear() var output = '<FORM><SELECT>'; for (var i=-7; i<7; i++) { aday = new Date(today.getYear(),today.getMonth(),today.getDate() + i) faday = padout(aday.getDate()) + '/' + padout((aday.getMonth() + 1)) + '/' + aday.getYear() output += '<OPTION '; if (faday==ftoday) output += ' SELECTED'; output += '>' + faday; } output += '<\/SELECT><\/FORM>'; document.write(output); //--></SCRIPT>