We help IT Professionals succeed at work.
Get Started

Hideshow action on radio onclick

751 Views
Last Modified: 2012-05-06
hi want to do a hide show concept in asp.net for radio button ,
Actually ..
i have a two radio button , on clicking one radio button ,

 it should open one text box .
if its clicked on other radio button this should
open two radiobutton with text box each and in this two radio button
 only  one  the radio button should be clicked and
that text control should be entered with values.......
.i tried like this but shows many js errors like objext expected  and syntax errors..
also i want to validate this form plz suggest..?
<script type="text/javascript">
function check()
{ if(document.forms[0].yes[0].checked == true && document.forms[0].yes[0].value == "video")
 { 
 document.forms[0].mess.style.display = "none"; 
 document.forms[0].video.style.display = "block";
 document.forms[0].audio.style.display = "block";
  document.forms[0].txtvideo.style.display = "block"; 
  document.forms[0].txtaudio.style.display = "block"; 
  else if(document.forms[0].yes[1].checked == true && document.forms[0].yes[1].value == "audio") 
 {
 document.forms[0].mess.style.display = "block"; 
 document.forms[0].video.style.display = "none";
 document.forms[0].audio.style.display = "none";
  document.forms[0].txtvideo.style.display = "none"; 
  document.forms[0].txtaudio.style.display = "none"; 
   }
   } 
   </script>
</head>
<body>
    <form id="Form2"  runat="server">
    <div>
        <input id="yes" name ="yes" type="radio" value="video" onclick="check();" />
        <input id="no" type="radio" name="yes" value="audio" onclick="check();"/>
        <input id="mess" name="mess" type="text" />
        <input id="video" name="video" type="radio" />
        <input id="audio" name="audio" type="radio" /><input name="txtvideo" id="txtvideo" type="text" />
        <input id="txtaudio" type="text"  name="txtvideo" />
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE