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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:01:57+00:00 2026-06-05T22:01:57+00:00

I am trying to make some project in which i want a text box

  • 0

I am trying to make some project in which i want a text box to be displayed when I select expert button and no text box when i click on learner button….

I have written this code but not able to get the problem… Plz some help…

<html>
<head>
<script language="javascript"> 

function toggleContent(showHideDiv, switchTextDiv) {
    var text = document.getElementById(showHideDiv);
    var ele = document.getElementById(switchTextDiv);
    var rad_val='';
    for (var i=0; i < document.text.role.length; i++)
    {
        if (document.text.role[i].checked)
        {
            rad_val = document.text.role[i].value;
        }
    }   

    if(rad_val=='learner'){
            ele.style.display = "block";
    }
    else {
        ele.style.display = "none";
    }
}
</script>
</head>
<body>
<table>
  <tr >
    <td  ><option value="1"> 1 </option>
    </td>
    <td> Role </td>
    <form id="form1">
      <td><label>
        <input type="radio" name="role" value='learner' onClick="toggleContent('form1','div1')" >
        Learner </label>
      </td>
      <td><label>
        <input type="radio" name="role" value='expert' onClick="toggleContent('form1','div1')" >
        Expert </label>
    </form>
<td ><div ID="div1" align=right style="display:none;">
        <label class="labell labelUser" >why?</label>
        <textarea name="description" align="right" id="description"  cols="40" rows="5" class="inputbox">Why?</textarea>
        <span id="descriptionError" class="notifyForUser" spanError></span> </div></td>  
  </tr>
  <tr >
    <td  ><option value="2"> 2 </option>
    </td>
    <td> Role </td>
    <form id="form2">
      <td><label>
        <input type="radio" name="role" value='learner' onClick=toggleContent('form2','div2') >
        Learner </label>
      </td>
      <td><label>
        <input type="radio" name="role" value='expert' onClick=toggleContent('form2','div2') >
        Expert </label>
      </td>
    </form>
    <td ><div ID="div2" align=right style="display:none;">
        <label class="labell labelUser" >why?</label>
        <textarea name="description" align="right" id="description"  cols="40" rows="5" class="inputbox">Why?</textarea>
        <span id="descriptionError" class="notifyForUser" spanError></span> </div></td>
  </tr>
</table>
</body>
</html>
  • 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-05T22:01:59+00:00Added an answer on June 5, 2026 at 10:01 pm

    This is the solution. Thanks @dragon66 to solve my issue.

    function toggleContent(showHideDiv, switchTextDiv) {
        var text = document.getElementById(showHideDiv);
        var ele = document.getElementById(switchTextDiv);
        var rad_val='';
        for (var i=0; i < text.role.length; i++)
        {
            if (text.role[i].checked)
            {
                rad_val = text.role[i].value;
            }
        }   
    
        if(rad_val=='learner'){
                ele.style.display = "block";
        }
        else {
            ele.style.display = "none";
        }
    }
    </script>
    </head>
    <body>
    <table>
      <tr >
        <td  ><option value="1"> 1 </option>
        </td>
        <td> Role </td>
        <form id="form1">
          <td><label>
            <input type="radio" name="role" value='learner' onClick="toggleContent('form1','div1')" >
            Learner </label>
          </td>
          <td><label>
            <input type="radio" name="role" value='expert' onClick="toggleContent('form1','div1')" >
            Expert </label>
        </form>
    <td ><div ID="div1" align=right style="display:none;">
            <label class="labell labelUser" >why?</label>
            <textarea name="description" align="right" id="description"  cols="40" rows="5" class="inputbox">Why?</textarea>
            <span id="descriptionError" class="notifyForUser" spanError></span> </div></td>  
      </tr>
      <tr >
        <td  ><option value="2"> 2 </option>
        </td>
        <td> Role </td>
        <form id="form2">
          <td><label>
            <input type="radio" name="role" value='learner' onClick=toggleContent('form2','div2') >
            Learner </label>
          </td>
          <td><label>
            <input type="radio" name="role" value='expert' onClick=toggleContent('form2','div2') >
            Expert </label>
          </td>
        </form>
        <td ><div ID="div2" align=right style="display:none;">
            <label class="labell labelUser" >why?</label>
            <textarea name="description" align="right" id="description"  cols="40" rows="5" class="inputbox">Why?</textarea>
            <span id="descriptionError" class="notifyForUser" spanError></span> </div></td>
      </tr>
    </table>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make extensive tests for my new project but I have a
I'm just starting out with postsharp/AOP. I want to make some instrumentation for C#
In the application that I am trying to make, I have a menu in
I have been trying to set up an EDE project for C++ (emacs24 +
I have been trying to get xapian working django haystack for a project im
Some Background: I make Box2D games using WCK, which is an alchemy port of
I'm trying to build some functionality for a project, but I'm stuck with this:
I'm trying to setup a development project for making a SharePoint solution. We have
I have been trying to figure this little section of my larger project out
I have posted a bit here related to a project I have been trying

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.