Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Make unique select entries from duplicates in  list

Posted on 2011-04-27
3
Medium Priority
?
287 Views
Last Modified: 2012-05-11
Hello,
Is there a JSP/jstl side way of creating a unique list/set on the fly.
I have to pull a series of user names  =  job.jobModifier from a list
and build a drop down with the results.
The problem is that there will be duplicates.
Is there a easy way of creating  a set from the list and using it to build the select entries ?

Thanks.

<td class="navWhite"  align="left"><b>User</b></td>
<td align="left">
<select name='userFilter' ID='userFilter' onchange="filerAllJobs();">      
<option VALUE=>ALL</option>
<c:forEach items="${jobList.jobList}" var="job" varStatus="status" >      
<option VALUE=>${job.jobModifier}</option>
<c:set var="uniqueUsers" value="${job.jobModifier}" />                
</c:forEach>
</select>
</td>
0
Comment
Question by:Waponi
3 Comments
 
LVL 28

Assisted Solution

by:rrz
rrz earned 200 total points
ID: 35480780
>Is there a JSP/jstl side way of creating a unique list/set on the fly.
You can't do it with JSTL. You could do it in a scriptlet, in a custom tag, in a tag file, or in a custom EL function.  
We can help you with whichever way you choose to do it.  
0
 
LVL 20

Accepted Solution

by:
Proculopsis earned 300 total points
ID: 35481304

You could try something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q__26981714.html</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

var userList = { "All": null };

<c:forEach items="${jobList.jobList}" var="job" varStatus="status">
userList["${job.jobModifier}"] = null;
<c:set var="uniqueUsers" value="${job.jobModifier}" />                 
</c:forEach>

jQuery(document).ready( function() {
 
  for ( var user in userList ) {
    $("#userFilter").append( $("<option/>").text( user ) );  
  };
 
});

</script>
</head>
<body>

<table>
  <tr>
    <td class="navWhite" align="left"><b>User</b></td>
    <td align="left">
    <select name='userFilter' ID='userFilter' onchange="filerAllJobs();">
    </select>
   </td> 
  </tr>
</table>

</body>
</html>

Open in new window

0
 

Author Closing Comment

by:Waponi
ID: 35805161
Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question