#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    4
    Rep Power
    0

    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. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    4
    Rep Power
    0
    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()) %>
    <% } %>

IMN logo majestic logo threadwatch logo seochat tools logo