|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Display Current Date In The Select Box
I am tyring to display a bunch of dates using the drop down menu is my jsp page using the following code:
Check Schedule For <select size="1" name="chk_Date"> <% cal.add(Calendar.DATE, -7); for (int i=0 ; i < 13; i++) { cal.add(Calendar.DATE, 1); %> <option value="cur"><%=(new java.text.SimpleDateFormat("MM/dd/yyyy")).format(cal.getTime()) %> <% } %> The select drop down display previous 6 days from current date & the future 6 dates from the current date. I want the drop down to show the current date when accessing this page. Right now it goes to the last date in the list, instead it should select the current date by default & display that in the drop down when this page is opened. Any ideas & any help would be highly; appreciated???? Thanks in advance..... |
|
#2
|
|||
|
|||
|
I solved my own problem....
Check Schedule For <select size="1" name="chk_Date"> <% cal.add(Calendar.DATE, -7); for (int i=0 ; i < 13; i++) { cal.add(Calendar.DATE, 1); %> <option value="cur" <%if (i==6) { %> selected <% } %>><%=(new java.text.SimpleDateFormat("MM/dd/yyyy")).format(cal.getTime()) %> <% } %> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Display Current Date In The Select Box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|