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 7880197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:05:11+00:00 2026-06-03T04:05:11+00:00

In a JSP file I use the following code to add attributes to elements

  • 0

In a JSP file I use the following code to add attributes to elements that belongs to a particular class :

    $($('.dhx_combo_input').get(0)).attr('style','width: 100%;<%=(highlight.get(0))?"background-color: #FF0000;":""%>');  
    $($('.dhx_combo_input').get(1)).attr('style','width: 100%;<%=(highlight.get(1))?"background-color: #FF0000;":""%>');  
    $($('.dhx_combo_input').get(2)).attr('style','width: 100%;<%=(highlight.get(2))?"background-color: #FF0000;":""%>'); 

highlight is an ArrayList<Boolean>.

I got many of those lines and only the index differ. It’s not really pretty nor concise so
I tried to replace it with a for loop but I need the index to be used in JS and Java. I’m not sure that it’s possible. Will I stay stuck with this syntax or is there a better solution?

Edit :

The loop has to be limited by the number of elements that belong to class dhx_combo_input.

  • 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-03T04:05:13+00:00Added an answer on June 3, 2026 at 4:05 am

    Unless I’m misunderstanding your question, you can do this:

    <%
        for(int i=0;...){
    %>
    
    $('.dhx_combo_input').eq(<%=i%>).attr('style','width: 100%;<%=(highlight.get(i))?"background-color: #FF0000;":""%>');
    
    <%
        }
    %>
    

    Note, I modified your jquery slightly to use eq instead of get so you don’t have to call jquery twice.

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

Sidebar

Related Questions

I have the following HTML in a JSP file: <div class=custList> <table class=dataGrid> <c:forEach
I have following piece of code in my jsp file which getSession information: <jsp:useBean
Inorder to use Spring Form Tags in JSP file following is taglib element I
I'm trying to use the following class in a JSP-based custom tag: public class
I am trying to use an image in the below index.jsp file in a
I have a .jsp file that receives a request and checks the request's parameters.
In my .jsp file I have the code below. How can I compare the
I am displaying ActionMessage s through a JSP file by the following command: <logic:messagesPresent
Assuming that requestScope.importMe is expecting a path to a JSP file <c:choose> <c:when test=${!empty
What methods do I need to add to a custom Java class so that

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.