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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:47:41+00:00 2026-05-28T13:47:41+00:00

elm = (‘cbProducts’ + suffix); _ctl = document.forms[0].elements[elm]; This works when there are more

  • 0
elm = ('cbProducts' + suffix);
_ctl = document.forms[0].elements[elm];

This works when there are more than 1 checkbox in my list.
But when there are only 1, _ctl is undefined.

Would rather use jQuery if possible and have something like:

elm = ('cbProducts' + suffix).trim();
_ctl = $("form :input #cbProducts*");

Next step is assigning length of _ctl (_ctl.length) but it is null for only 1 checkbox in the elements collection.

  • 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-28T13:47:41+00:00Added an answer on May 28, 2026 at 1:47 pm

    So you want all inputs whose ids start with cbProducts?

    $("form input[id^='cbProducts']");
    

    or do you want inputs with cbProducts anywhere in the id?

    _ctl = $("form input[id*='cbProducts']");
    

    and of course _ctl.length will give you the number of elements in this set.


    EDIT

    Based on your comment, if you know the id you’re looking for, instead of this:

    $("form input[id='cbProducts' + elm]");
    

    opt for this

    $("#cbProducts" + elm);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this wrong? If so why? var elm = document.getElementById(myElm); elm.customValue = {attr1 :
I bind two event handlers on this link: <a href='#' id='elm'>Show Alert</a> JavaScript: $(function()
Is there a limit to the number of simultaneous Ajax requests than can be
How would I perform the following in jQuery? var elmOperator = document.getElementById(elm.id.replace('Include', 'Operator')); The
how to copy an object with some elements? I want to copy this object,
How can I change this code to take advantage of jQuery? function download(elm) {
I need to do something like this: <ul><li>something</li></ul> <div class='elm'>click me</div> <!-- no 1
If i use some really simple code like : $('#elm').tipTip(); It will do what
function countChars(elm) { if (elm.nodeType == 3) { // TEXT_NODE return elm.nodeValue.length; } var
i've an xml file like <node> <elm val=data1/> <elm val=data2/> <elm val=data3/> <elm val=data4/>

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.