SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    griffith
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to Hide form field based on dropdown choice

    Dropdown has three choices. If the third is chosen, the next field needs to be hidden. is there an ASP version of a show/hide script?

  2. #2
    SitePoint Member
    Join Date
    May 2005
    Location
    Ohio
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note that I don't know much, but I'd imagine it'd be similar to

    Code:
     
    <% 
    strWhatever = Replace(Request.Form("nameofdropdown"), "'", "''") 
    If strWhatever = OptionFromDropDown then %> 
    <!--#include file='includes/adminmenu.inc'--> 
    <% Else %> 
    <!--#include file='includes/usersmenu.inc'--> 
    <% End If %>
    I'm probably wrong though

  3. #3
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Looks good to me Strypes.

    Keep in mind this is considering you are posting the form. If you want something client side then search for a JavaScript solution.

  4. #4
    SitePoint Zealot TheTank's Avatar
    Join Date
    May 2003
    Location
    Houston, TX
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah that would cause a page have to reload. Javascript forum would be best. I would stick the form element in a <div> and set the style to 'none' with an onchange event of the dropdown.
    I think sometimes I dream in code.

  5. #5
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to be a pain, instead of using:
    Code:
      <% 
      strWhatever = Replace(Request.Form("nameofdropdown"), "'", "''") 
      If strWhatever = OptionFromDropDown then %> 
      <!--#include file='includes/adminmenu.inc'--> 
      <% Else %> 
      <!--#include file='includes/usersmenu.inc'--> 
      <% End If %>
    Try using the Server.Execute()
    Code:
       <% 
       strWhatever = Replace(Request.Form("nameofdropdown"), "'", "''") 
       If ( strWhatever = OptionFromDropDown ) then
        Server.Execute("includes/adminmenu.inc")
     Else
        Server.Execute("includes/usersmenu.inc")
     End If
     %>


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
  •