SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drop down dependent on radio button

    I need to find a script where I can display a drop down menu dependent on whether or not a radio button is clicked. Can anyone help me out?

  2. #2
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    working code
    Code:
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.0
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && document.getElementById) x=document.getElementById(n); return x;
    }
    
    function MM_showHideLayers() { //v3.0
      var i,p,v,obj,args=MM_showHideLayers.arguments;
      for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
        obj.visibility=v; }
    }
    //-->
    </script>
    </head>
    
    <body bgcolor="#FFFFFF" text="#000000">
     
    
    
    
     
    
    
    <p> </p>
    <form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td width="33%">
    	<input type="radio" name="radiobutton" value="Yes" onClick="MM_showHideLayers('dropdown','','hide')">
    	<input type="radio" name="radiobutton" value="No" onClick="MM_showHideLayers('dropdown','','show')">
    	</td>
      </tr>
      <tr> 
        <td>
    	<div style="height: auto">
    	<div id="dropdown" style="position:absolute; visibility: visible; z-index: 2">
    	      <select name="select" size="1">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
              </select>
    	</div>
    	
    	</div>
    	</td>
      </tr>
    </table>
    </form>
    <p>&nbsp;</p>
    </body>
    </html>

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Daniel,

    For a different solution, see the "Hiding Selects" script/tutorial at my site.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •