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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:04:30+00:00 2026-06-01T10:04:30+00:00

I am able to toggle through a js function that uses href id for

  • 0

I am able to toggle through a js function that uses href id for matching to the corresponding div or td to toggle.

But My goal is to be able to toggle the div/td with another href that is found at the bottom of the page. This href contains the same id and name.

Here is an example:jsfiddle (The toggle function works in my remote server but it doesn’t somehow in jsfiddle)

<script type="text/javascript">

function showonlyonev2(thechosenone) {
      var newboxes = document.getElementsByTagName("div");
      for(var x=0; x<newboxes.length; x++) {
            name = newboxes[x].getAttribute("name");
            if (name == 'newboxes-2') {
                  if (newboxes[x].id == thechosenone) {
                        if (newboxes[x].style.display == 'block') {
                              newboxes[x].style.display = 'none';
                        }
                        else {
                              newboxes[x].style.display = 'block';
                        }
                  }else {
                        newboxes[x].style.display = 'none';
                  }
            }
      }
}​
</script>

<table>
   <tr>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader1-2" href="javascript:showonlyonev2('newboxes1-2');" >toggle</a>
         </div>
         <div name="newboxes-2" id="newboxes1-2" name="div1" style="border: 1px solid black; background-color: #CCCCCC; display: block;padding: 5px;">Div #1</div>
      </td>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader2-2" href="javascript:showonlyonev2('newboxes2-2');" >toggle</a>
         </div>
         <div name="newboxes-2" id="newboxes2-2" name="div2" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #2</div>
      </td>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader3-2" href="javascript:showonlyonev2('newboxes3-2');" >toggle</a>
         </div>
         <div name="newboxes-2" id="newboxes3-2" name="div3" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #3</div>
      </td>
   </tr>
</table>


<div style="padding-top:20px;">
    <a id="myHeader1-2" name="div1" href="javascript:showonlyonev2('newboxes1-2');">See Div #1</a>  
</div>    

<div style="padding-top:20px;">
    <a id="myHeader2-2" name="div2" href="javascript:showonlyonev2('newboxes2-2');">See Div #2</a>  
</div>

<div style="padding-top:20px;">
    <a id="myHeader3-2" name="div3" href="javascript:showonlyonev2('newboxes3-2');">See Div #3</a>  
</div>    ​
  • 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-01T10:04:32+00:00Added an answer on June 1, 2026 at 10:04 am

    It is unusual to have a “name” attribute on a div.

    The divs in the top table have 2 “name” attributes each.

    I would clean it up and try again.

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

Sidebar

Related Questions

I'm trying to use JQuery toggle functionality, but not able to use properly. Instead
I have a DIV on my page that I want to be able to
Hi i just want to be able to toggle to hide/show a div respectively
For my particular application, I want to be able to toggle a radiobutton on
I would like to programmatically check the value of, and be able to toggle
I have a number of table rows that I would like to toggle the
I'm working on a Mac app that uses a toolbar in it's main window.
I need to be able to handle data that can look like: set setting1
I have an Android app that uses ActionBar Sherlock. I create a menu that
I want to be able to toggle the bold on/off for a UILabel, all

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.