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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:57:25+00:00 2026-05-16T00:57:25+00:00

In my web application, I’ve set of checkboxes which on check populate a textbox

  • 0

In my web application, I’ve set of checkboxes which on check populate a textbox above them.(If more than one checkbox is selected, then their values appear in the textbox separated by commas).

These set of checkboxes appear as rows in my HTML table.

Here’s my HTML code.

<input type="text" id="newContactComment<%=rCount %>" name="newContactComment" size="45">

<input type="checkbox" id="commentText<%=rCount %>" name="commentText" value="<%=c.getComment_text() %>" 
        onclick="javascript:updateTextArea(<%=rCount%>);"> 

And the corresponding JS function is as follows:

function updateTextArea(rCount) {
    var allVals = new Array();          
    $("#contactInfo input['commentText' + rCount]:checked").each(function() {
        (allVals).push($(this).val());
    });

    $("#newContactComment" + rCount).val(allVals);
}

The rCount variable in the above function is the row # of my table.
Using this above, I’m not getting the expected behaviour..
For ex. If for row 1 of my table, I check chkbox 1 and 2, it correctly gets populated with values of those checkboxes. Now, for 2 of my table, I check only chkbox 3, it gets populated with the values 1,2 and 3 and not only 3 as I expect it to.

Any help will be greatly appreciated.

  • 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-16T00:57:26+00:00Added an answer on May 16, 2026 at 12:57 am

    It would be better to use jQuery to set an event handler rather than setting it inline.

    You want to use the onchange event not the onclick event.

    If you add class names of checkboxes (or whatever you want) to the checkboxes the following will work:

    $("input.checkboxes").change(function(){ //when checkbox is ticked or unticked
    
    
       var par = $(this).closest("tr")[0];
       var parID = par.id;
       var patt1=/([0-9]+)$/g;
       var rCount = parID.match(patt1); //Gets number off end of id
    
       var allVals = new Array(); 
    
       //Get all checkboxes in current row that are checked         
       $(par).find("td input.checkboxes:checked").each(function() {
          allVals.push($(this).val());
       });
    
       $("#newContactComment" + rCount).val(allVals);
    
       allVals = null; //empty array as not needed
    
    });
    

    I believe this or something along these lines will do what you want

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

Sidebar

Related Questions

my web application has more than one user with unique usercode. As soon as
Our web application is deployed in a web farm (more than 20 servers). The
My web application generates pdf files and either e-mails or faxes them to our
My web application (MonoRail, Windsor, ActiveRecord) has a Startable import service and one or
In web application, i am created one new project in that i added class
A web application we wrote intended for one customer is going to be product-ized
My web application contains a text box for which I would like to restrict
My web application has two search pages - search1.jsf and search2.jsf - which share
My web application I am creating features a lot of grids, and one baffling
One web application of ours requires a feature of displaying charts in it. Basically

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.