• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problem with dropdown list

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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

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

<html:option value="1">01</html:option>

<html:option value="2">02</html:option>

<html:option value="3">03</html:option>

<html:option value="4">04</html:option>

<html:option value="5">05</html:option>

<html:option value="6">06</html:option>

<html:option value="7">07</html:option>

<html:option value="8">08</html:option>

<html:option value="9">09</html:option>

<html:option value="10">10</html:option>

<html:option value="11">11</html:option>

<html:option value="12">12</html:option>

<html:option value="13">13</html:option>

<html:option value="14">14</html:option>

<html:option value="15">15</html:option>

<html:option value="16">16</html:option>

<html:option value="17">17</html:option>

<html:option value="18">18</html:option>

<html:option value="19">19</html:option>

<html:option value="20">20</html:option>

<html:option value="21">21</html:option>

<html:option value="22">22</html:option>

<html:option value="23">23</html:option>

<html:option value="24">24</html:option>

<html:option value="25">25</html:option>

<html:option value="26">26</html:option>

<html:option value="27">27</html:option>

<html:option value="28">28</html:option>

<html:option value="29">29</html:option>

<html:option value="30">30</html:option>

<html:option value="31">31</html:option>

</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.

 
Ranch Hand
Posts: 87
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic