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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:33:00+00:00 2026-05-28T05:33:00+00:00

I currently have 4 textboxes, 1 checkbox and a dropdownlist. I am attempting to

  • 0

I currently have 4 textboxes, 1 checkbox and a dropdownlist. I am attempting to disable the textboexes and dropdownlist upon
the checkbox being checked. My current code does not work, but I can’t seem to find the error in it. I am new to using JavaScript.

function enableCheckBox(phyAddressCheckBox, tb1, tb2, tb3, file1, tb4)
{
    if (document.getElementById(phyAddressCheckBox).checked) 
{
document.getElementById('tb1').enabled = true;
document.getElementById(tb2).enabled = true;
document.getElementById(tb3).enabled = true;
document.getElementById(file1).enabled = true;
document.getElementById(tb4).enabled = true;
}
else
{
document.getElementById(tb1).enabled = false;
document.getElementById(tb2).enabled = false
document.getElementById(tb3).enabled = false;
document.getElementById(file1).enabled = false;
document.getElementById(tb4).enabled = false;
}
}

edit
I set all property to disabled on both conditions and nothing works.

<script type="text/javascript" language="javascript">
function enableCheckBox(phyAddressCheckBox, tb1, tb2, tb3, file1, tb4)
{
    if (document.getElementById(phyAddressCheckBox).checked) 
{
    document.getElementById('tb1').disabled = 'disabled';
document.getElementById(tb2).disabled = 'disabled';
document.getElementById(tb3).disabled = 'disabled';
document.getElementById(file1).disabled = 'disabled';
document.getElementById(tb4).disabled = 'disabled';
}
else
{
document.getElementById(tb1).disabled = 'disabled';
document.getElementById(tb2).disabled = 'disabled';
document.getElementById(tb3).disabled = 'disabled';
document.getElementById(file1).disabled = 'disabled';
document.getElementById(tb4).disabled = 'disabled';
}
}
</script>

I also added in the control code.

<asp:CheckBox ID="phyAddressCheckBox" runat="server"  onclick="enableCheckBox(this.ID, physicalAddressTextbox, PhysicalAddress2Textbox, CityTextbox, physicalStateDropDownList,physicalZipTextbox)" style="text-align: left" />
  • 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-28T05:33:01+00:00Added an answer on May 28, 2026 at 5:33 am

    I disagree with the people telling you to use disabled='disabled' The disabled property on input elements takes a boolean, unlike the HTML attribute. https://developer.mozilla.org/en/DOM/HTMLInputElement

    From the names of the variables you’re passing into enableCheckBox, it looks like you’re passing DOM nodes instead of ids.

    Another problem is that you’re passing this.ID, you should be passing this.id. Even better, just pass the element itself. See this example http://jsfiddle.net/mendesjuan/7ZEvk/2/

    The last problem (in initial example) was that you were trying to set an enabled property, but that doesn’t exist. You have to set the disabled property.

    HTML

    <input type='checkbox' id='cbox' onclick="enableCheckBox(this, 'text1', 'text2', 'text3', 'sel');"/>
    
    <input id='text1' />
    <input id='text2' />
    <input id='text3' />
    <select id='sel'>
        <option>hello</option>
    </select>
    

    JavaScript

    // This is a lot like your function, but is less repetitive
    function enableCheckBox(cbox /*, ... ids of fields to enable/disable */){    
        for (var i = 1; i < arguments.length; i++) {
            document.getElementById(arguments[i]).disabled = cbox.checked;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have 4 textboxes which will be used to store an ip address.
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
Currently in my application I have two possible textboxes. One for a local image
I have the following code in mypage, .... <input type=checkbox title=Warehouse1 name=warehouse[] id=selectedUser_1 class=select_checkbox
My data is being correctly loaded on my page. However I have 2 textboxes
TextBoxes and NumericUpDowns have the odd property of not allowing you to deselect them
I have a WPF usercontrol which contains a number of textboxes and buttons. Currently
I currently have two text boxes which accept any number. I have a text
I currently have an MS Access application that connects to a PostgreSQL database via
I currently have speakers set up both in my office and in my living

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.