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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:58:57+00:00 2026-05-24T00:58:57+00:00

This should have been pretty straightforward using the DOM but I seem to be

  • 0

This should have been pretty straightforward using the DOM but I seem to be getting undefined errors.

Basically, I’m trying to say, when a user clicks a button hide one form and replace it with another. Hiding it should have been as simple as setting style.display : none; but it seems style is constantly undefined.

Here’s the script

function hideTextForm()
{
    var textForm = document.getElementsByClassName("my-text-form");
    //var formContent = textForm.contentDocument;

    console.log(formContent);
    //textForm.visibility='false';
    //textForm.visible(false);
    //textForm.style.visibility = "hidden";
    //formContent.display = "none";

    formContent.style.display = "none";
    console.log(textForm);
    /*this returns:
     <div class="my-list-form">
     <form id="list-form" class="list-form" name="list-form">
     <label>list form here</label>
     </form>
     </div>*/

    console.log("Text form should be hidden");
}

This is only half the different attempts. My gut tells me that the way I’m calling the element is wrong with getElementsByClassName. I’m either calling the wrong element or trying to display it wrong.

Heres the HTML:

<div class="analysis">
            <div class="analysis-columns">
                <div class="analysis-static">
                    <table align = "left" border ="1" id="static-column-table" class="my-columns" >
                        <tr id="tr-static">
                            <th id="table-comment-head">
                                <b>Comments</b>
                            </th>
                        </tr>
                        <tr><td><button class="column-button" value="Page Description">Page Description</button></td></tr>
                        <tr><td><button class="column-button" value="Keywords">Keywords</button></td></tr>
                        <tr><td><button class="column-button" value="Files">Files</button></td></tr>
                        <tr><td><button class="column-button" value="Internal Links">Internal Links</button></td></tr>
                        <tr><td><button class="column-button" value="External Links">External Links</button></td> </tr>

                    </table>
                </div>

                <div class="analysis-custom">
                    <table border ="1" align="right" id="custom-column-table" class="my-columns" >
                        <tr id="tr-custom">
                            <th>Custom</th>
                        </tr>
                        <tr><td><button class="column-button" value="Page Description">Page Description</button></td></tr>
                        <tr><td><button class="column-button" value="Keywords">Keywords</button></td></tr>
                        <tr><td><button  value="Add">Add New Field+</button></td></tr>

                    </table>
                </div>


            </div>
            <div class="analysis-form">

                <input type="radio" name="type-of-row" value="List" title="List" onclick="hideTextForm();"/> List</br>
                <input type="radio" name="type-of-row" value="Text"  title="Text" onclick="hideListForm();"/> Text</br>

                <select>
                    <optgroup label="Type of Row">
                        <option>List</option>
                        <option>TextBox</option>
                    </optgroup>
                </select>
                </br>

                <div class="my-list-form">
                    <form name ="list-form" class = "list-form" id="list-form">
                        <label>list form here</label>
                    </form>
                </div>
                <div class="my-text-form">
                    <form name="text-form" class = "text-form" id="text-form">
                        <label>text form here</label>
                        <!--<textarea cols="30" rows="2">Enter the name of your new Row here...</textarea>
                   <button  value="Page Description" onclick="addRow()">New TextField</button>-->
                    </form>
                </div>

            </div>
</div>

And finally relevant CSS:

div.analysis
{
    padding: 1px;
    width: 100%;
    border: .2em solid #ffcc00;
}
div.analysis-columns
{
    /* border-style: solid;*/
    border: .2em solid #900;
    float: left;
    width:55%;
    /*border: 5;
    border-color: #8a2be2;*/
    display: inline;

}
div.analysis-static
{
    margin: auto;
    padding: 1px;
    width:47%;
    float:left;
    border: .2em solid #0000ff;
    /*border: 3;
    border-color: #0000FF;*/
    /*border-collapse:collapse;*/
    font-family: Century Gothic, sans-serif;

}
div.analysis-custom
{
    margin: auto;
    border: .2em dotted #FFFFDD;
    padding: 1px;
    float: right;
    width:47%;
}
div.analysis-form
{
    margin: auto;
    width:43%;
    border: .2em ridge #b22222;
    float: right;
}
div.my-list-form
{
    display: inherit;
}
div.my-text-form
{
    display: inherit;

}

If anyone is having trouble visualizing it or running it, basically I have a small panel called analysis. Within this panel, is 2 tables (left) and one changing form on the right.
my-list-form and my-text-form should be the only css to worry about.

I’m convinced I’m calling the element wrong so please take a look at document.getElem(“my-text-form”) and what it returns.

  • 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-24T00:58:57+00:00Added an answer on May 24, 2026 at 12:58 am

    Have a look at the method you’re calling — getElementsByClassName. Look at what it returns. It is not a DOM element — it is something called a NodeList. This is an object a bit like an array (though technically not an array) that contains all the elements with that class name. A NodeList doesn’t have a style property, so you can’t set it.

    You need to get the first element in the NodeList (using the array notation [0]) and set the style property of that.

    var textForm = document.getElementsByClassName("my-text-form")[0];
    textForm.style.display = 'none';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

another Objective-C one for you, probably pretty obvious but I have been at this
This should be pretty straightfoward and I don't know why I am struggling with
I have found this example on StackOverflow: var people = new List<Person> { new
I'm trying to build a C++ extension for python using swig. I've followed the
I have been looking for help online on how to design my php classes
I have a new web app that is packaged as a WAR as part
I have a login.jsp page which contains a login form. Once logged in the
I am using a 3rd-party rotator object, which is providing a smooth, random rotation
This is beyond both making sense and my control. That being said here is
I want to use a temp directory that will be unique to this build.

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.