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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:39:49+00:00 2026-05-26T06:39:49+00:00

Hi I am trying to get this JavaScript work for me. Can any one

  • 0

Hi I am trying to get this JavaScript work for me.

Can any one help me with this.

When user clicks the Check box the next text box should disable,
if unchecked then enable.

selectors are working fine when I debug scrip in IE9 developer tool.

function is running fine as needed.

<input id="RefillNeeded10" name="RefillasNeeded" type="checkbox" value="true">
<input type="text" size="5" id="RefillTB10," name="Refills">

$('input[type="checkbox"][name^="RefillasNeeded"]').click(function () {
var num = $(this).attr('id').replace("RefillNeeded", "");
if ($('input[type="checkbox"][id="RefillNeeded' + num + '"]').attr("checked")) {
  $('input[type="text"][id="RefillTB' + num + '"]').attr("disabled", true);
                   }
  else {
  $('input[type="text"][id="RefillTB' + num + '"]').attr("disabled", false);
   }
 });

but $('input[type="text"][id="RefillTB' + num + '"]').attr("disabled", true);
this is not creating the attribute disable.

I have this listed here for convenience.

  • 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-26T06:39:50+00:00Added an answer on May 26, 2026 at 6:39 am

    Your selector isn’t matching any elements. It looks like you have a typo in your HTML – there is a trailing , in the id of the text box. Remove the comma from your id attribute, and it should work. http://jsfiddle.net/gilly3/KJVCa/13/


    By the way, you don’t need that big long selector to get the checkbox and test if it is checked. You already have a reference to it as this. And you can just check its checked property:

    if (this.checked)
    

    While we’re at it, why not really simplify things. You don’t need to parse the id, just get the next element (assuming your textbox always follows your checkbox). You don’t need an if, just use the boolean directly. Your code can be shrunk down to just this:

    $("input[type=checkbox][name^=RefillasNeeded]").click(function () {
        $(this).next().attr("disabled", this.checked);
    });
    

    See it here: http://jsfiddle.net/gilly3/KJVCa/15/

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

Sidebar

Related Questions

I have been trying everything I can to get this script to work and
I am trying to get a JavaScript object to use the this assignments of
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
I've been trying to get this code to work for hours! All I need
I'm trying to get this css layout to work with IE7 and I'm a
I've been trying to get this module to work and no matter what I've
Hi I am trying to get this to show up a separate box for
If there's anyone who can help me understand this one, I will be impressed.
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I'm trying to get this simple PowerShell script working, but I think something is

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.