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

username and password cannot be resolved or is not a field
How page directive “extend” in jsp works?
Simple property not found?
Reusing JSP custom tags inside html
JSP Quiz process is not giving me the correct percentage scored
Refer the id variable of logic - iterate using jstl-el
Invalid tagdir attribute while web-fragment is used
JSP foreach tag for two variables
Adding Parameter to href tag before uri
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

Categories

HOME
pdf
minimum-spanning-tree
google-play
youtube-dl
framework7
umd
convolution
ios-charts
metatrader4
offline
numeral.js
modelica
jplayer
n-gram
moonmail
gz
visual-studio-cordova
dosgi
libtiff
ef-migrations
visual-composer
custom-wordpress-pages
cloudhub
bootstrap-tour
one-to-many
su
centos6.5
kannel
greendao
assistant
jspm
binary-data
oracle-fusion-middleware
pdb
grails-3.1
windows-dev-center
android-nestedscrollview
bitbucket-pipelines
jquery-bootgrid
service-discovery
xenforo
ssjs
leading-zero
awt
reportingservices-2005
jvm-languages
glew
heightmap
netcdf4
strptime
datastax-startup
togetherjs
gcsfuse
sonarlint-vs
home-directory
mikroc
py2app
essence
whois
netmq
pervasive-sql
srand
endeca-workbench
emailrelay
microbenchmark
graph-drawing
sankey-diagram
graph-api-explorer
c3
network-interface
android-imagebutton
javafx-webengine
socketexception
p4java
typo3-neos
commoncrypto
gridfs
spring-io
quartz-graphics
plasma
factory-method
mhtml
unc
broken-links
word-processor
objective-c-2.0
parametric-equations
netdna-api
php-parser
libc++
spyware
rfc1123
yetanotherforum
netbeans-7.1
jmock
radcombobox
asp.net-mvc-areas
coda-slider
user-friendly
multi-tier
misv

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
Mobile App
Mobile App
Mobile App