Skip to main content

developerWorks >  WebSphere  >  Forums  >  Portal and Portlet Development  >  developerWorks

It this not possible with JSTL    Point your RSS reader here for a feed of the latest messages in this thread


Tags for this thread: 

     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
This question is answered.

Permlink Replies: 2 - Pages: 1 - Last Post: Nov 2, 2009 2:17 AM Last Post By: miq
miq

Posts: 27
Registered: Aug 13, 2007 08:44:18 AM
It this not possible with JSTL
Posted: Oct 30, 2009 06:03:05 AM
 
Click to report abuse...   Click to reply to this thread Reply
Anybody can tell why following code to create a Dropdown box does not show the values correct in the list.
My intention is that the value from my request should bee selected.
All the values are prefixed with following selected<

<SELECT name="montno" onChange="selectChanged(this);">
<OPTION value=1><c:if test="${requestScope.numberoffmonth=='1'}">selected</c:if>>1</OPTION>
<OPTION value=2><c:if test="${requestScope.numberoffmonth=='2'}">selected</c:if>>2</OPTION>
<OPTION value=3><c:if test="${requestScope.numberoffmonth=='3'}">selected</c:if>>3</OPTION>
<OPTION value=4><c:if test="${requestScope.numberoffmonth=='4'}">selected</c:if>>4</OPTION>
<OPTION value=5><c:if test="${requestScope.numberoffmonth=='5'}">selected</c:if>>5</OPTION>
<OPTION value=6><c:if test="${requestScope.numberoffmonth=='6'}">selected</c:if>>6</OPTION>
<OPTION value=7><c:if test="${requestScope.numberoffmonth=='7'}">selected</c:if>>7</OPTION>
</SELECT>
bgould

Posts: 64
Registered: Jan 16, 2007 04:18:50 PM
Re: It this not possible with JSTL
Posted: Oct 30, 2009 09:49:04 AM   in response to: miq in response to: miq's post
 
Click to report abuse...   Click to reply to this thread Reply
You have some syntax problems with your option:

<OPTION value=1><c:if test="${requestScope.numberoffmonth=='1'}">selected</c:if>>1</OPTION>


After the "value" attribute, you have an extra
>


try this instead:

<OPTION value="1" <c:if test="${requestScope.numberoffmonth=='1'}">selected</c:if>>1</OPTION>


if you are using JSP 2.0 (servlet 2.4) you could make it a little cleaner like this:

<OPTION value="1" ${requestScope.numberoffmonth == '1' ? 'selected' : ''}>1</OPTION>
miq

Posts: 27
Registered: Aug 13, 2007 08:44:18 AM
Re: It this not possible with JSTL
Posted: Nov 02, 2009 02:17:56 AM   in response to: bgould in response to: bgould's post
 
Click to report abuse...   Click to reply to this thread Reply
Thanks at all.
The real problem was that I had forgot to include the Package name and the tag was closed after value .
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums