获取下拉框多选器
Fetch drop down box multi selector
我编写此程序是为了从数据库中获取下拉式多重选择器 数据,并显示多重选择器的所有选项,并突出显示所选选项和其余选项。
<% 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>
<%
/*从数据库中获取技能数组*/
String[] skills = (String[]) request.getAttribute("skills");
/* 在 drop do 中写下所有可用的选项*/
String[] allSkills = { "Core Java", "J2ee", "Spring", "Hibernate", "Sql", ".net"
>%
/* 多重选择器的代码将是 */
<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>
我编写此程序是为了从数据库中获取下拉式多重选择器 数据,并显示多重选择器的所有选项,并突出显示所选选项和其余选项。
<% 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>
<%
/*从数据库中获取技能数组*/
String[] skills = (String[]) request.getAttribute("skills");
/* 在 drop do 中写下所有可用的选项*/
String[] allSkills = { "Core Java", "J2ee", "Spring", "Hibernate", "Sql", ".net"
>%
/* 多重选择器的代码将是 */
<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>