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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:01:22+00:00 2026-05-31T10:01:22+00:00

I have a jsp page in which there is a html table. The contents

  • 0

I have a jsp page in which there is a html table. The contents of the table will be populated dynamically after reading an xml file. Depending on some data present in the xml file, the number of rows in the table may vary from 2 to 10. Now, there is a checkbox in each row that is displayed in the html table. The id of the checkbox is also dynamically named. Now, I have to write some javascript code which is dependent on all the ids of the the checkboxes that are displayed. How to pass all the ids of the checkboxes that are displayed on the table to the javascript code dynamically?

PS: Im thinking of this approach, please correct me if im wrong. Declare an empty array to hold ids of the checkboxes. As I create each row of the table dynamically using a for-loop, I add the ids of the checkboxes to the array. Now, Im thinking to use this array in the javascript.

Is it possible to access this array in the javascript? If so, How do I pass on this array to the javascript block? Are there any restrictions on where to place this javascript code in the jsp(like after/before the code block where the ids of the checkboxes get added to the array). Im relatively new to this kind of stuff. Pls help on implementing this approach

  • 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-05-31T10:01:23+00:00Added an answer on May 31, 2026 at 10:01 am

    if I understood you have two possibilities. You could

    1. add the id of the checkbox to a javascript array for every iteration on the server-side for loop. So you need to declare an empty js array at the begin of your page , then you add a script block for each checkbox, in which you push the id into the array with <yourarray>.push("<yourid>"). This solution is not really performant (since each <script> block stops the rendering process for a while and you “sow” the code in several places) but technically is working – otherwise

    2. at DOM ready (or onload) event you look at the input:checkbox DOM collection, get the id and push it into the array, like so.

      var ids = [],
          cbx = document.querySelectorAll('input[type="checkbox"]');
      
      for (i = 0, l = cbx.length; i < l; i++) {
             ids.push(cbx[i].id);
      }
      
      console.log(ids);
      

    Fiddle: http://jsfiddle.net/G44hH/1/ – Of course if you can, it’s better if use this solution (and not the first one)

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

Sidebar

Related Questions

I have a project which will be made up mostly of Java Servlets, JSP/Html
i have a jsp page in which there are three functions on onclick event.
I have a JSP page in which there is a hyperlink to add a
I have a jsp page which simply prints {result : success} and there is
I have a jsp page which should load a popup using ajax. The content
I have a JSP page which accepts SQL queries, performs them then returns the
I have a JSP page, which accepts user strings in more than 23 languages.
Hi I have a page in my java/jsp based web application which shows list
I have a functional JSP page that accepts URL parameters and updates a table
I have created a jsp file, with a simple table on it. I would

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.