jsp-tags


Fetch drop down box multi selector


I have written this program to fetch the drop down multi selector data from the data base and show all the options of multi selectors with highlighting the selected ones with the rest options.
<% String[] skills=(String[])request.getAttribute("skills");
//skills[]={"Core Java","Hibernate","Sql}; // it is dynamic d
String[] allSkills={"Core Java","J2ee","Spring","Hibernate","Sql",".net"};
%>
<tr>
<td>Skills Known</td>
<td><select name="skills" multiple STYLE="width: 148px">
<% for(int i=0;i<allSkills.length-1;i++){
for (int j=0;j<skills.length-1;j++){
if(allSkills[i].equals(skills[j])){%>
<option value=<%=allSkills[i] %> selected="selected"><%=allSkills[i] %></option>
<%return; %>
<%}else if(j==skills.length-1){%>
<option value=<%=allSkills[i] %>><%=allSkills[i] %></option>
<%}
}
}%>
</select>
</td>
</tr>
<%
/* get the skills as a array from the data base*/
String[] skills = (String[]) request.getAttribute("skills");
/* write all the options availbale in the drop do*/
String[] allSkills = { "Core Java", "J2ee", "Spring", "Hibernate", "Sql", ".net"
>%
/* the code for multiple selector will be */
<tr>
<td>Skills Known</td>
<td><select name="skills" multiple STYLE="width: 148px">
<%
for (int counter = 0; counter < allSkills.length; counter++) {
int status = 0;
for (String str : skills) {
if (!(str.equalsIgnoreCase(allSkills[counter]))) {
continue;
} else {
status++;
}
}
if (status > 0) {
%>
<option value="<%=allSkills[counter]%>" selected="selected"><%=allSkills[counter]%></option>
<%
} else {
%>
<option value="<%=allSkills[counter]%>"><%=allSkills[counter]%></option>
<%
}
}
%>
</select></td>
</tr>

Related Links

Servlet exception stream closed jsp
creating and exporting a csv from Display tag table
bean write to number type id
restrict image file size in alloy UI
The function getContextPath must be used with a prefix when a default namespace is not specified
how can i retrive parameters from EncodeURL using jsp?
onclick tag giving error in h:commandLink
Displaytag - How to pass hidden value in url?
Embedding Tag Files in a JAR
Errors when the compiler is trying to build a custom JSP tag based on an Java Bean
Creating nested custom tag using jsp2 tag files
Unable to access session on JSP
Dealing with <html:options>
No tag “tableFacade” defined in tag library imported with prefix “jmesa”
how to refer values of one jsp file to other jsp
incorrect username and passwords

Categories

HOME
listview
coq
netbeans
server
reserved
relative-path
office365api
grep
cakephp-2.5
ezpublish
enterprise-library-5
uber-api
swagger-ui
upload
synchronization
virtualization
adobe-analytics
vault
correlation
moonmail
gz
dynamics-crm-online
finite-automata
aurigma
swiftlint
clickonce
opencover
arabic
greendao
pdb
rotational-matrices
file-format
devextreme
jquery-bootgrid
scaffold
occlusion
streamsets
uft-api
leading-zero
sas-visual-analytics
particles.js
email-templates
modelmapper
outlook-2013
osx-mavericks
komodoedit
winscp-net
python-cryptography
jspdf-autotable
django-scheduler
time-and-attendance
abcpdf9
visual-c++-2008
angular-cache
httplistener
underscore.js-templating
mongocsharpdriver
prettytensor
rvest
captivenetwork
kendonumerictextbox
reactive-banana
icu4j
collapse
comobject
quicklisp
android-listview
riak-cs
composite
unity5.2.3
dia
coldbox
javafx-webengine
codeigniter-routing
document-classification
starcluster
hippomocks
rtmfp
meteor-velocity
viadeo
uv-mapping
c18
tidy
ruby-datamapper
pushbackinputstream
interface-orientation
jelly
kyotocabinet
coderush
google-email-migration
word-processor
reddot
cufon
table-footer
lpeg
blitz++
filtered-index
castle-monorail
rescale
mediarss
data-acquisition

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html