Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:35:41+00:00 2026-06-12T00:35:41+00:00

In my web application I need to display a drop down dynamically loaded from

  • 0

In my web application I need to display a drop down dynamically loaded from database.
I need to load the list of users from DB. Each user will have ‘access level’ as 1 or 2.
When the users are displayed in the dropdown they must have an image in the side of their name.
(like ‘Green’ tick for ‘access level’ 1) and (red cross for access level 2).
I have checked this url http://www.marghoobsuleman.com/jquery-image-dropdown.
But I need to to display the image based on the access level loaded from DB.
I guess this can be done by JQuery/CSS.

Can anyone please tell how this can be done and if possible sample code please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:35:42+00:00Added an answer on June 12, 2026 at 12:35 am

    Since you are using jsp as view technology, use core tags to decide whether you want to show green tick or red cross depending upon the access level.

    Visit this site to know more about the usage of core tags. Don’t forget to include jstl.jar and standard.jar files in your project classpath. They are necessary libraries which support jstl.

    Looks like your application is developed using spring framework, so I’ll try to explain it that way only.

    Your JSP code will be something like this: name it userlist.jsp

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <!doctype>
    <html>
        <head>
           <script src="${pageContext.request.contextPath}/js/jquery-1.3.2.min.js" type="text/javascript></script>
           <script src="${pageContext.request.contextPath}/js/jquery.dd.js" type="text/javascript"></script>
           <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/dd.css" />
        </head>
        <body>
            <form:select id="userNames" path="userName" tabindex="10">
                <form:option value="Select User">Select User</form:option>                
                <c:forEach begin="${userlist begin index (0)}" end="${userlist size}" var="i">
                    <c:choose>
                        <c:when test="${userNameList.user.accessLevel == 1}">
                            <form:option style="background-image:url(greentick.png);" value="${userNameList.user.userName}">${userNameList.user.userName}</form:option>
                        </c:when>
                        <c:otherwise>
                            <form:option style="background-image:url(redcross.png);" value="${userNameList.user.userName}">${userNameList.user.userName}</form:option>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
            </form:select>
        </body>
    </html>
    

    Now you will have a controller which will be called after invoking some action and it will return this jsp along with userNameList.
    Below is sample UserController.java

    @Controller
    public class UserController {
    
        @RequestMapping(value = "/showUsers", method = RequestMethod.GET)
        public String showUserInfo(Model model) {
            // here you prepare the userList, the list of Users along with information
            // here User can be fetched from DB & values stored in User DTO and then DTO in the list
            List<User> userNameList = new ArrayList<User>();
            userNameList.add(User DTO objects go here);
            model.addAttribute("userNameList", userNameList);
            return "userlist";       // remember this is our jsp name
        }
    }
    

    & User DTO can be something like this.
    Below is sample User.java

    public class User {
        private String userName;
        private int accessLevel;
    
        // setters & getters of variables
    }
    

    This can’t be fully articulated answer. I have tried my best to explain.
    You give this a try. It should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We need to display JBoss log files from within our web application. Is it
My web application as a topbar where i need to display the number of
I'm developing a simple web application where in I need to display number a
In the java web application need to select the file from server and print
I am building a web application that will need to allow users to save
I'm writing a web application where I need to pass some user data to
I need to tidy user input in a web application so that I remove
I need to display charts in a web application developped with spring mvc. What's
For some reason I need to display tabular data in my web application but
I'm developing a Web application. I need to display some decimal data correctly so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.