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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:18:39+00:00 2026-06-01T11:18:39+00:00

<script> function unhide(divID) { var item = document.getElementById(divID); if (item) { item.className=(item.className==’hidden’)?’unhidden’:’hidden’; } }

  • 0
    <script>
    function unhide(divID) {
    var item = document.getElementById(divID);
    if (item) {
    item.className=(item.className=='hidden')?'unhidden':'hidden';
    }
    }
    </script>

    <style>
    .hidden { display: none; }
    .unhidden { display: block; }
    </style>

    <div class="answers">
        <ol>
            <li>
                <input type="radio" name="q1" id="q1-a" onclick="unhide('answerq1a')"/>John
            </li>
            <li>
                <input type="radio" name="q1" id="q1-b" onclick="unhide('answerq1b')"/>Paula
            </li>
            <li>
                <input type="radio" name="q1" id="q1-c" onclick="unhide('answerq1c')"/>Henal
            </li>
            <li>
                <input type="radio" name="q1" id="q1-d" onclick="unhide('answerq1d')"/>Malc
            </li>
        </ol>
    </div>

    <div id="answerq1a" class="hidden">
    <textarea class="widthninetyfivepercent" rows="4" name="optionA" id="1-A" maxlength="300" value=""/>Your answer is correct, John is 20.</textarea>
    </div>

This works fine, but the only problem is, I am using radio buttons and I want on a click to show my div (which it does) but when another radio button is clicked, I want it to hide all other unhidden divs, and only show one at a time.

How can I go about this in the simplest way?

You may find some stuff is written in a weird way, but that is because I need this to be edited using a CMS and it will only pick it up in a specific way. That is also why I am using this specific show/hide. It is short and it works with the way I’ve written everything.

Regards,

John Vas.

  • 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-01T11:18:41+00:00Added an answer on June 1, 2026 at 11:18 am

    Without changing your html or code much DEMO

    <input type="radio" name="q1" id="q1-a" onclick="unhide(this)" />
    <input type="radio" name="q1" id="q1-b" onclick="unhide(this)" />
    <input type="radio" name="q1" id="q1-c" onclick="unhide(this)" />
    <input type="radio" name="q1" id="q1-d" onclick="unhide(this)" />
    

    using

    var currentShown = "";
    function unhide(rad) {
      var id = "answer"+rad.id.replace("-",""); 
      var answer = document.getElementById(id);
      if (answer) {
        var current = document.getElementById(currentShown);
        if (current) current.className="hidden";
        currentShown=id;
        answer.className="unhidden";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have this script: function ajax(){ if (navigator.standalone) return; for (var i= document.links.length;
The JS script: function ShowUploadingAnimation() { $('#info_msg').html(<div style=\padding-top: 15px; height: 50px;\ align=\center\><img id=\uploading-img\ /></div>);
I need a java script function that converts the document object of the current
to custom validate an input i wrote a script: function cardNumberCheck(value, element) { var
Hay, i'm using this script function preloader(images){ var i = 0; imageObj = new
I have the following script: function add_fields(link, association, content) { var new_id = new
Have next script: function clicker(){ var linkId = [id*= + link]; var butnId='initial'; $j(linkId).click(function(){
I have this simple script: function orientation() { var orientation = window.orientation; switch(orientation) {
I have this script: function slideSwitch() { var ae = jQuery('#featured-right a.active'); if (
Found this script: function stopRKey(evt) { var evt = (evt) ? evt : ((event)

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.