Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build an HTML select option list in Play

I want to do something similar in Play and Java:

<select id="birthyear" name="birthyear">
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
</select>

However I want to be able to give it a start year and an end year and build the select list dynamically.

I ame across this but in Scala and Play, but I'm not sure how to accomplish this in Java/Play?

UPDATE: Read the documentation as provided in the answer and also checked the sample projects that came installed with Play and used the following

<div>
     Select birth year of  
     #{select 'yob', items:2012..1900, value:5, id:'select3' /}
   </div>
like image 513
user721264 Avatar asked Feb 04 '26 04:02

user721264


1 Answers

Playframework has built in tag #{select} to achive this.

Please go thru the below link, It will help you,

http://www.playframework.org/documentation/1.1/tags#select

like image 164
Selvakumar Ponnusamy Avatar answered Feb 06 '26 02:02

Selvakumar Ponnusamy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!