Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Hide/Show Div when selecting radio button

Hide/Show Div when selecting radio button

Scheduled Pinned Locked Moved ASP.NET
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M K BASHER
    wrote on last edited by
    #1

    Hi I have two div in my web page and two radio button I want initially both div will be invisible.When i am selecting one radio button i want one div will be visible and other will be invisible I am using IE-7 please help me

    D P H V 4 Replies Last reply
    0
    • M M K BASHER

      Hi I have two div in my web page and two radio button I want initially both div will be invisible.When i am selecting one radio button i want one div will be visible and other will be invisible I am using IE-7 please help me

      D Offline
      D Offline
      Dev S
      wrote on last edited by
      #2

      u can use javascrpit function for this like: function showdiv1() { document.getElementById('div1').style.display='block'; // to display document.getElementById('div2').style.display='none'; // to hide } and make similar function for div2 and call them on selection of radiobutton.

      M 1 Reply Last reply
      0
      • D Dev S

        u can use javascrpit function for this like: function showdiv1() { document.getElementById('div1').style.display='block'; // to display document.getElementById('div2').style.display='none'; // to hide } and make similar function for div2 and call them on selection of radiobutton.

        M Offline
        M Offline
        M K BASHER
        wrote on last edited by
        #3

        I tried it but it is not working

        A D 2 Replies Last reply
        0
        • M M K BASHER

          I tried it but it is not working

          A Offline
          A Offline
          Alok Sharma ji
          wrote on last edited by
          #4

          try the ajax accordian pane thats the real fast way to do it in asp and also you can find it on google or codeplex for this third party dll and the functions working can be seen on asp.net/samples.If you want more then these are deeply described in wrox asp.net prof. buy the book. byee, cheers

          1 Reply Last reply
          0
          • M M K BASHER

            I tried it but it is not working

            D Offline
            D Offline
            Dev S
            wrote on last edited by
            #5

            set display:none of ur div where u have defiend ur div so that intially it is not visible. There is nothing like which woultd not work try it and tell me exatcly what problem is coming.

            1 Reply Last reply
            0
            • M M K BASHER

              Hi I have two div in my web page and two radio button I want initially both div will be invisible.When i am selecting one radio button i want one div will be visible and other will be invisible I am using IE-7 please help me

              P Offline
              P Offline
              PauloCastilho
              wrote on last edited by
              #6

              You can do it just using JavaScript. Download jQuery 1.3.2[^] and test the code below. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>DIV show / hide example</title> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#box_dv div').each(function() { $(this).hide(); }); $('#box_rdo input:radio').each(function() { $(this).click(function() { $('#box_dv div').hide(); $('#' + $(this).attr('value')).show(); }); }) }); </script> </head> <body> <div> <div id="box_rdo"> <input type="radio" id="r1" name="rdo" value="d1" /><label for="r1">DIV 1</label> <input type="radio" id="r2" name="rdo" value="d2" /><label for="r2">DIV 2</label> </div> <br /> <div id="box_dv"> <div id="d1"> <h1>DIV 1</h1> This is the DIV 1 content! </div> <div id="d2"> <h1>DIV 2</h1> This is the DIV 2 content! </div> </div> </div> </body> </html> If you gonna use asp.net server controls, instead of <input type="radio"> and <div> use asp:RadioButtonList and asp:Panel... Handle the OnSelectedIndexChanged event of the radio button list to manipulate the visibility of the asp:panel's (div's).

              modified on Monday, April 6, 2009 12:47 PM

              1 Reply Last reply
              0
              • M M K BASHER

                Hi I have two div in my web page and two radio button I want initially both div will be invisible.When i am selecting one radio button i want one div will be visible and other will be invisible I am using IE-7 please help me

                H Offline
                H Offline
                Hajab
                wrote on last edited by
                #7

                The sample javascript is below. function showdiv() { //To hide div document.getElementById("DIV").style.display='none'; //To show div document.getElementById("DIV").style.display='block'; } .... ....

                .... ....

                ..... Use this in your code as per your requirement and this should definitely help you out.

                1 Reply Last reply
                0
                • M M K BASHER

                  Hi I have two div in my web page and two radio button I want initially both div will be invisible.When i am selecting one radio button i want one div will be visible and other will be invisible I am using IE-7 please help me

                  V Offline
                  V Offline
                  vivek_r
                  wrote on last edited by
                  #8

                  Make both the divs runat='server' and assign them some ID

                  and write your code according to that. e.g. on Page_Load if u want to both the divs invisible then : div1.Visible= false; div2.Visible= false; Similarly you can write code according to the radio button selection.

                  Happy Coding, Vivek Rathore

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups