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

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

Categories

HOME
yii2
vim
winforms
gerrit
json.net
fme
infragistics
jgroups
v8
dxl
binary-tree
survey
directx
maude-system
tomcat6
offline
phaser
carthage
caml
django-simple-history
pc
footer
jqwidget
oxyplot
google-cloud-speech
shared-hosting
viewport
claims-based-identity
django-storage
internet-explorer-9
atlassian-crucible
kendo-datasource
nat
bluestacks
react-chartjs
titanium-mobile
http-get
noraui
winrt-xaml-toolkit
openoffice.org
form-data
mmenu
picasso
nssegmentedcontrol
fusionpbx
libraries
unobtrusive-validation
dynamic-reports
heightmap
websphere-mq-fte
angular2-meteor
executenonquery
scorm
termination
pubmed
python-webbrowser
statsd
nativeapplication
iso8601
lync-client-sdk
watchconnectivity
parallel-data-warehouse
asp.net-4.5
skobbler-maps
qpid
rvest
hsv
kendonumerictextbox
cyclomatic-complexity
iis-arr
wyam
embedded-code
sailfish-os
fluid-dynamics
sortedlist
python-green
website-monitoring
gulp-less
code-access-security
terminfo
yorick
shellexecute
spring-validator
type-equivalence
distutils
simba
cascalog
online-compilation
wse3.0
removeclass
sproutcore-2
vc90
ncqrs
audio-capture
privilege
scripting-languages
geneva-server

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