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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:11:38+00:00 2026-06-06T15:11:38+00:00

I want to disable an input Box AND a button when a checkbox is

  • 0

I want to disable an input Box AND a button when a checkbox is clicked .

My markup :

<h4>Random or Not </h4>

    <!-- Use Random Image -->  

    <label><input name="o99_aufu_options[o99_aufu_random]" id="o99_aufu_options[o99_aufu_random]" value="1" checked="checked" type="checkbox">Use Random Image ? <em></em></label><br>  

    <!-- If the above not checked - needs to be enabled -->                         
    Upload Image <label for="upload_image"> <input id="upload_image" size="36" name="o99_aufu_options[o99_aufu_upload_image]" value="" type="text"> <input id="upload_image_button" value="Choose Image or upload" type="button"> </label>

jQuery :

if (jQuery('#o99_aufu_options[o99_aufu_random]').is(':checked')) {
       jQuery('#upload_image :input').attr('disabled', true);
    } else {
        jQuery('#upload_image_button,#upload_image :input').removeAttr('disabled');
    }   

well – obviously, if i am asking here – it is not working 🙂

Fiddle :

http://jsfiddle.net/obmerk99/6jFMf/3/

Also as a bonus question – is it possible to do that only with the NAME of the input, omitting the ID from the markup ?

UPDATE I – working solution :

http://jsfiddle.net/obmerk99/6jFMf/20/

  • 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-06-06T15:11:38+00:00Added an answer on June 6, 2026 at 3:11 pm

    bonus question – is it possible to do that only with the NAME of the input, omitting the ID from the markup ?

    You can use any attribute in a jQuery selector, including name:

    $('[name="foo"])
    

    Since your names have brackets, you’ll probably have to escape them:

    $('[name="o99_aufu_options\[o99_aufu_random\]"]')
    

    You can also qualify them to specific elements if you want, or combine them with other selectors:

    $('input.someClass[name="o99_aufu_options\[o99_aufu_random\]"]')
    

    As for your actual question, my first guess … is wrong is that your problem is whitespace; have you tried:

    #upload_image:input
    

    instead?

    My second guess is also wrong that the problem is:

    .prop('disabled', true);
    

    Have you tried:

    .prop('disabled', 'disabled');
    

    ?

    Ok, I actually looked at your fiddle, and there were a few things wrong; here’s a working example, let me know if you have questions, but hopefully it’s self-explanatory:

    jQuery(function() {
        jQuery('input[name="o99_aufu_options\[o99_aufu_random\]"]').click(function(){
            var isChecked = jQuery(this).is(':checked') ;
            jQuery('#upload_image:input').prop('disabled', isChecked? 'disabled' : null);
        })
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML: <label class=fileinput-button> <span>add file...</span> <input type=file name=file disabled> </label>
I want to disable the left bar button when my webview is loading can
I want to disable or also I have does not give permission entering the
I want to enable/disable a text box based on selection of drop down items
I want to disable the jQuery event if a Text box is in focus.
Just making a very very simple order form. Want a input box ( only
I want to disable a set of checkbox based on selection of one textbox
I have div with Textbox, label and hyperlink it it. I want to disable
I want to enable the input field when check box is checked. Also, I
I have a box i want to animate when clicked on a link. The

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.