Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

array problem with a selected index  RSS feed

 
mary morris
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I was going to use the following code which works well to get a selected index- of months:
<%
String passedBirthDateMonth = (String) request.getParameter("birthDateMonth");
if (passedBirthDateMonth==null) passedBirthDateMonth="0";
String birthMonths[] = {
"January" , "February" , "March" , "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int bM = Integer.parseInt( passedBirthDateMonth )-1;
%>
------and-----
<select name="birthDateMonth" >
<OPTION >Month
<%
String mSelect1 = "";
for (int i=0;i<birthMonths.length;i++) {
if (i==bM) mSelect1 = "selected";
else mSelect1 = "";%>
<option value="<%= i %>"<%= mSelect1 %>><%= birthMonths[i] %></option><%
}%>
</select>
-------------------
But I need the months to start at
<option value=1>January ..<option value="11">December
not:
<option value="0">January...<option value=12>December
is there anyway around this problem, without resorting to another way???
Thanks!!!
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

increment the value by one...
[ April 13, 2002: Message edited by: Brian Glodde ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or put in a "" empty string at the start of the array - I do that frequently, its the lazy programmer's way.
 
mary morris
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replys. I will try both ways.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!