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

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
creating the welcome page
How to use list object in <c:forEach tag?
How to call a Servlet when I click on a Hyperlink
EL Messages on JSP page
showmodaldialog function in ie8

Categories

HOME
osgi
cloud
deployment
gerrit
urbancode
reflection
fluentd
dictionary
reserved
plot
homebrew
electron
cplex
mean-stack
spagobi
jsp-tags
bookshelf.js
setup-deployment
amazon-ecs
dxl
icloud
ravendb
fingerprint
acquia
upload
esper
elasticsearch-hadoop
dacpac
modx-revolution
google-apps-marketplace
visual-studio-cordova
jsprit
highlight.js
angular-ui
serilog
normalizr
textfield
predix
orleans
mps
restful-authentication
autosys
icloud-api
opennlp
sparse-matrix
facet
xacml
google-cloud-nl
gsmcomm
nouislider
microsoft-chart-controls
titanium-mobile
mapdb
fusionpbx
mixture-model
jna
unixodbc
flashair
gpx
theming
jlink
winscp-net
pg-dump
qtwebview
cudafy.net
spring-mongodb
color-profile
smart-table
pintos
angular-strap
radtreelist
sts-springsourcetoolsuite
asp.net-4.5
autorest
prettytensor
prerequisites
lemon
0xdbe
cakephp-3.1
web-controls
truevault
website-monitoring
codeigniter-url
android-nested-fragment
rdtsc
nsbutton
titanium-modules
fluentautomation
picturefill
ms-project-server-2010
.aspxauth
listings
jelly
robotics-studio
factory-method
jquery-knob
google-email-migration
word-processor
manchester-syntax
armcc
osql
nsmanagedobject
punbb
netbeans-7.1
propagation
oncheckedchanged
lang
nsviewanimation
libs
mediarss
genealogy
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