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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:31:27+00:00 2026-05-30T03:31:27+00:00

I need to enable 3 buttons, after checking the LAST check box on my

  • 0

I need to enable 3 buttons, after checking the LAST check box on my page using JS. The code I currently have is as follows:

<script type="text/javascript">
<!--
window.onload=function() {
  df=document.forms[0];
  df[1].disabled=true;
  df[0].onclick=function(){
  df[1].disabled=(df[1].disabled)?false:true;
  }
  df=document.forms[0];
  df[2].disabled=true;
  df[1].onclick=function(){
  df[2].disabled=(df[2].disabled)?false:true;
  }
   df=document.forms[0];
  df[3].disabled=true;
  df[2].onclick=function(){
  df[3].disabled=(df[3].disabled)?false:true;
  }
    df=document.forms[0];
  df[4].disabled=true;
  df[3].onclick=function(){
  df[4].disabled=(df[4].disabled)?false:true;
  }
    df=document.forms[0];
  df[5].disabled=true;
  df[4].onclick=function(){
  df[5].disabled=(df[5].disabled)?false:true;
  }
    df=document.forms[0];
  df[6].disabled=true;
  df[5].onclick=function(){
  df[6].disabled=(df[6].disabled)?false:true;
  }
    df=document.forms[0];
  df[7].disabled=true;
  df[6].onclick=function(){
  df[7].disabled=(df[7].disabled)?false:true;
  }
    df=document.forms[0];
  df[8].disabled=true;
  df[7].onclick=function(){
  df[8].disabled=(df[8].disabled)?false:true;
  }
    df=document.forms[0];
  df[10].disabled=true;
  df[8].onclick=function(){
  df[10].disabled=(df[10].disabled)?false:true;
  }
 }
//-->

I need to add two more buttons to this script. When I script it this way, it only works with the last button.

<script type="text/javascript">
<!--
window.onload=function() {
  df=document.forms[0];
  df[1].disabled=true;
  df[0].onclick=function(){
  df[1].disabled=(df[1].disabled)?false:true;
  }
  df=document.forms[0];
  df[2].disabled=true;
  df[1].onclick=function(){
  df[2].disabled=(df[2].disabled)?false:true;
  }
   df=document.forms[0];
  df[3].disabled=true;
  df[2].onclick=function(){
  df[3].disabled=(df[3].disabled)?false:true;
  }
    df=document.forms[0];
  df[4].disabled=true;
  df[3].onclick=function(){
  df[4].disabled=(df[4].disabled)?false:true;
  }
    df=document.forms[0];
  df[5].disabled=true;
  df[4].onclick=function(){
  df[5].disabled=(df[5].disabled)?false:true;
  }
    df=document.forms[0];
  df[6].disabled=true;
  df[5].onclick=function(){
  df[6].disabled=(df[6].disabled)?false:true;
  }
    df=document.forms[0];
  df[7].disabled=true;
  df[6].onclick=function(){
  df[7].disabled=(df[7].disabled)?false:true;
  }
    df=document.forms[0];
  df[8].disabled=true;
  df[7].onclick=function(){
  df[8].disabled=(df[8].disabled)?false:true;
  }
    df=document.forms[0];
  df[10].disabled=true;
  df[8].onclick=function(){
  df[10].disabled=(df[10].disabled)?false:true;
  }
    df=document.forms[0];
  df[11].disabled=true;
  df[8].onclick=function(){
  df[11].disabled=(df[11].disabled)?false:true;
  }
    df=document.forms[0];
  df[12].disabled=true;
  df[8].onclick=function(){
  df[12].disabled=(df[12].disabled)?false:true;
  }
 }
//-->
</script>

DF’s 12,11,10 & 9 are buttons. I need button 1 or DF 9 enabled always. I need buttons 2,3 & 4 or DF’s 10,11 & 12 to “enable” when my last check box is checked. This checkbox is DF 8. Please help!

  • 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-30T03:31:29+00:00Added an answer on May 30, 2026 at 3:31 am

    This code is not self-documenting. It’s therefore very hard to maintain it and to get it understood by other developers. I strongly recommend you to work on that as well. Start using sensible variable names and so on.

    But I think I see the problem. You’re overriding the onclick handler of df[8] everytime by reassigning it instead of attaching a new function to the existing handler. This way only the last assigned onclick function will really execute.

    So, instead of

    df=document.forms[0];
    df[10].disabled=true;
    df[8].onclick=function(){
        df[10].disabled=(df[10].disabled)?false:true;
    }
    df=document.forms[0];
    df[11].disabled=true;
    df[8].onclick=function(){
        df[11].disabled=(df[11].disabled)?false:true;
    }
    df=document.forms[0];
    df[12].disabled=true;
    df[8].onclick=function(){
        df[12].disabled=(df[12].disabled)?false:true;
    }
    

    you need to do

    df = document.forms[0];
    
    df[10].disabled = true;
    df[11].disabled = true;
    df[12].disabled = true;
    
    df[8].onclick = function() {
        df[10].disabled = !df[10].disabled;
        df[11].disabled = !df[11].disabled;
        df[12].disabled = !df[12].disabled;
    }
    

    (note that I also simplified the way how you’re toggling the disabled attribute)

    Again, your code is not self-documenting. This may or may not solve your real problem.

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

Sidebar

Related Questions

I have a Button on appwidget, that I need to 'enable'/'disable' programmatically from a
I need to enable/disable completely network interfaces from a script in Windows XP. I'm
I need to write robust code in .NET to enable a windows service (server
I need to disable the buttons in UIActionSheet. after some operations i need to
I need to be able to enable and disable a linkbutton using javascript as
I currently have several action buttons in different pages, and each button performs some
Hi all i have my form with some controls as follows 2 Radio buttons
I have a code which has set of buttons listening for touch events. for
I need to enable the mcrypt functions on my website, except I'm on a
I need to enable/disable post comments regarding the value of a new field in

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.