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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:21:45+00:00 2026-05-23T16:21:45+00:00

First the setup: jquery 1.5.1 Firefox 4.0 Goal: I’ve got a bunch of textboxes

  • 0

First the setup:
jquery 1.5.1
Firefox 4.0

Goal:
I’ve got a bunch of textboxes that are enabled/disabled using checkboxes. If a textbox is enabled, I want it to have a value greater than zero.

HTML for one of the boxes(there are a variable number of them on the page):

<input type="text" value="0" name="RequestList[4].iCount" id="RequestList_4__iCount" class="num-box">

My jQuery using .each that doesn’t work:

var oneFill = false;
$('.num-box').each(function() {
    var myItem = $(this);
    if (myItem.attr('disabled') == false) {
        if (myItem.val() > 0) {
            oneFill = true;
        }
    }
});
if (!oneFill) {

When I trace the above code in Firebug, it doesn’t do anything. It continues to the next line of code(if(!oneFill)).

When I use $(‘.num-box’) in Firebug, it returns a complete list of all textboxes. So I’m very confident that I’ve got the right selector.

So the question is, what did I do wrong? I’ve looked at a host of examples here and it appears my use of .each was correct.

But, is there a more efficient method for checking all enabled textboxes with class of num-box?

Addition1
@artlung
Using continuing my sample html above, I would have at least the following:

<input type="text" value="0" name="RequestList[1].iCount" id="RequestList_1__iCount" class="num-box">
<input type="text" value="0" name="RequestList[2].iCount" id="RequestList_2__iCount" class="num-box">
<input type="text" value="0" name="RequestList[3].iCount" id="RequestList_3__iCount" class="num-box">
<input type="text" value="0" name="RequestList[4].iCount" id="RequestList_4__iCount" class="num-box">

The checkboxes would look like:

<input type="checkbox" value="true" name="RDEquipListItem[1]" id="RDEquipListItem_1_">
<input type="checkbox" value="true" name="RDEquipListItem[2]" id="RDEquipListItem_2_">
<input type="checkbox" value="true" name="RDEquipListItem[3]" id="RDEquipListItem_3_">
<input type="checkbox" value="true" name="RDEquipListItem[4]" id="RDEquipListItem_4_">

I’ve got java script that enables/disables the textboxes when the appropriate checkbox is checked.

So far, I’ve seen some good adjustments to the meat of my code. I will vote for those tomorrow.

My confusion is whether there is an issue with my .each portion:

$('.num-box').each(function() {

Addition2
I’ve been playing with some of the results. My current code looks like:

var oneFill = false;
var myEnabled = $('.num-box:enabled');
myEnabled.each(function() {
    var myItem = $(this);
    if (parseInt(myItem.val()) > 0) {
        oneFill = true;
    }
});
if (!oneFill) {

myEnabled gets the correct list of elements that are enabled. thumbs up

However, the myEnabled.each does nothing.

Is there an issue with a single item being used by .each?

Final comment
Not sure why this was giving me an issue but I had to reorder the logic a bit. Even using Firebug, it wouldn’t step into the “.each” code but the results are correct.

Final code(NOTE: .num-box are textboxes that are enabled/disabled by checkboxes):

//make sure one item has been filled in and all are greater than zero
var allFilled = true;
var myEnabled = $('.num-box:enabled');
//check that we have at least one item checked out
if (myEnabled.length == 0) {
    alert("At least one needs to be filled.");
    return false;
}

$.each(myEnabled, function() {
    var myItem = $(this);
    if (parseInt(myItem.val()) <= 0) {
        allFilled = false;
    }
});
if (!allFilled)
{
    //go do something
  • 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-23T16:21:45+00:00Added an answer on May 23, 2026 at 4:21 pm

    Try this

    var oneFill = false;
    $('.num-box').each(function() {
        var myItem = $(this);
        if (myItem.is(":enabled") && parseInt(myItem.val()) > 0) {
                oneFill = true;
    
        }
    });
    if (!oneFill) {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just got setup on my first Windows Server 2008 / IIS7.5 server for
First here's what I'm using and trying to do: the minimal setup for this
My setup is a little complicated so let me go over that first. We
Here's my setup. I'm using .NET: I have a Main.aspx lets call it. That
I am using the comet long-polling technique with apache, php, jquery. I've got a
I'm using jQuery Tools Scrollable with this setup . I'm having trouble changing the
I'm using coldfusion and jquery. This is my first real go at jquery and
I am using the jQuery Validation plugin and have an issue validating items that
I am using jquery datatables for html table generation. I setup a callback to
I have setup a sidebar via the jQuery API. Now I noticed that when

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.