This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Problem with dropdown list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with dropdown list " Watch "Problem with dropdown list " New topic
Author

Problem with dropdown list

Deepak Sahu
Greenhorn

Joined: Dec 08, 2009
Posts: 16
Hi All,

I have a code for a dropdown list of 1-31.

<html:select styleId="fullTimingDay" property="fullTimingDay" size="1" >

<htmlption value="1">01</htmlption>

<htmlption value="2">02</htmlption>

<htmlption value="3">03</htmlption>

<htmlption value="4">04</htmlption>

<htmlption value="5">05</htmlption>

<htmlption value="6">06</htmlption>

<htmlption value="7">07</htmlption>

<htmlption value="8">08</htmlption>

<htmlption value="9">09</htmlption>

<htmlption value="10">10</htmlption>

<htmlption value="11">11</htmlption>

<htmlption value="12">12</htmlption>

<htmlption value="13">13</htmlption>

<htmlption value="14">14</htmlption>

<htmlption value="15">15</htmlption>

<htmlption value="16">16</htmlption>

<htmlption value="17">17</htmlption>

<htmlption value="18">18</htmlption>

<htmlption value="19">19</htmlption>

<htmlption value="20">20</htmlption>

<htmlption value="21">21</htmlption>

<htmlption value="22">22</htmlption>

<htmlption value="23">23</htmlption>

<htmlption value="24">24</htmlption>

<htmlption value="25">25</htmlption>

<htmlption value="26">26</htmlption>

<htmlption value="27">27</htmlption>

<htmlption value="28">28</htmlption>

<htmlption value="29">29</htmlption>

<htmlption value="30">30</htmlption>

<htmlption value="31">31</htmlption>

</html:select>


Instead of writing 31 times <html:select> </html:select>,please anyone provide solution to achieve this in a scalable way so that by writing less no of code we can achieve this.

Aniket S. Kulkarni
Ranch Hand

Joined: Jun 15, 2011
Posts: 87

Try this:

<html:select styleId="fullTimingDay" property="fullTimingDay" size="1" >
<% for(int i=1;i<32;i++)
{
%>
<option value="<%=i%>"><%=i%>  </option>
<% }
%>
</html:select>

I hope this will help you.


Aniket Kulkarni
Oracle Certified Professional, Java SE 6 Programmer.
 
Don't get me started about those stupid light bulbs.
 
subject: Problem with dropdown list
 
Similar Threads
Trees in Java
Help, lunarcal.js
Birthday Calendar
Problem moving columns and rows in 2D array.
Magic Square water retention