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

  • Home
  • SEARCH
  • 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 578701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:17:19+00:00 2026-05-13T14:17:19+00:00

I was kindly helped by Jonathan over here simple javascript question-linking button state to

  • 0

I was kindly helped by Jonathan over here simple javascript question-linking button state to image swap?

The problem is that this makes the “active” class the same class for both list items.

Each list item needs to toggle its own active and its own inactive class (each is a button with its own css styling and background image).

Can you please help me modify the script so that I can do that?

Here is Jonathans provided code:

<li class="transcript">
   <a id="transcriptionhorbutton" class="inactive"
      href="javascript:void()" 
      onclick="getDataReturnText('/lessons/transcriptions/ajaxcalls/L1horizontal.txt', callback);make_active(this);"></a>
</li>
<li class="transcript">
   <a id="transcriptionvertbutton" class="inactive"
      href="javascript:void()" 
      onclick="getDataReturnText('/lessons/transcriptions/ajaxcalls/L1vertical.txt', callback);make_active(this);"></a>
</li>

<script>

var buttons = [ document.getElementById("transcriptionvertbutton"), 
                document.getElementById("transcriptionhorbutton")];

function make_active(el) {
  deactivate_buttons();
  el.setAttribute("class","active");
}

function deactivate_buttons() {
  buttons[0].setAttribute("class","inactive");
  buttons[1].setAttribute("class","inactive");
}
</script>

I understand that the problem is here:

function make_active(el) {
  deactivate_buttons();
  el.setAttribute("class","active");
}

but I don’t know enough to separate that into two different classes.

  • 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-13T14:17:19+00:00Added an answer on May 13, 2026 at 2:17 pm

    Just add an extra parameter to the function:

    function make_active(el, classname) {
      deactivate_buttons();
      el.setAttribute("class",classname);
    }
    

    Then change your calls just a bit. Here is the completed code. Note I changed all calls of setAttribute to .className instead. This was just so you don’t run into any trouble with IE6:

    <li class="transcript">
       <a id="transcriptionhorbutton" class="inactive"
          href="javascript:void()" 
          onclick="getDataReturnText('/lessons/transcriptions/ajaxcalls/L1horizontal.txt', callback);make_active(this,'active_class_1');"></a>
    </li>
    <li class="transcript">
       <a id="transcriptionvertbutton" class="inactive"
          href="javascript:void()" 
          onclick="getDataReturnText('/lessons/transcriptions/ajaxcalls/L1vertical.txt', callback);make_active(this,'active_class_2');"></a>
    </li>
    
    <script>
    
    var buttons = [ document.getElementById("transcriptionvertbutton"), 
                    document.getElementById("transcriptionhorbutton")];
    
    function make_active(el, classname) {
      deactivate_buttons();
      el.className = classname;
    }
    
    function deactivate_buttons() {
      buttons[0].className = "inactive_class_1";
      buttons[1].className = "inactive_class_2";
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 288k
  • Answers 288k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you don't need a back button and since part… May 13, 2026 at 5:24 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately, you cannot. IIS has always been tied to an… May 13, 2026 at 5:24 pm
  • Editorial Team
    Editorial Team added an answer With user extensions, generally, you are on your own -… May 13, 2026 at 5:24 pm

Related Questions

I was kindly helped a few minutes ago by a user named Juliano and
I was recently visiting a site and noticed that the page had a section
I was trying to compile and project file ,taken freshly from the VSS and
I was enjoying using YARD a lot: http://www.ootl.org/yard/ http://code.google.com/p/yardparser/ http://www.codeproject.com/KB/recipes/yard-tokenizer.aspx I was able to
I am new to using XPath and this may be a basic question. Kindly

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.