Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable drop down

    I have 2 drop downs where I want the second one to be disabled. It will only be enabled after the first drop down has been selected.

    Here is my attempt but not working because the second drop down is always enabled:
    Code:
    <script>
    function enableField()
    {
    if(document.myname.movie.value != "")
    {
       document.myname.television.disabled=true;
    }
    }
    </script>
    
    
    <form name="myname" method="post" action="mypage.jsp">
    <select name = "Movie" onselect="enableField()";>
    <option value = "">Select One</option>
    <option value = "I am Legend">I am Legend</option>
    <option value = "Wedding Crashers">Wedding Crashers</option>
    <option value = "Jaws">Jaws</option>
    </select>
    
    <select name = "Television">
    <option value = "">Select One</option>
    <option value = "CSI">CSI</option>
    <option value = "Amercian Idol">American Idol</option>
    <option value = "60 Minutes">60 Minutes</option>
    </select>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    <script type="text/javascript">
    function enableField(obj)
    {
    if(obj.value != "")
     document.myname.Television.disabled=false;
    }
    </script>
    Code:
    <form name="myname" method="post" action="mypage.jsp">
    <select name = "Movie" onchange="enableField(this)";>
    <option value = "">Select One</option>
    <option value = "I am Legend">I am Legend</option>
    <option value = "Wedding Crashers">Wedding Crashers</option>
    <option value = "Jaws">Jaws</option>
    </select>
    
    <select name = "Television" disabled="disabled">
    <option value = "">Select One</option>
    <option value = "CSI">CSI</option>
    <option value = "Amercian Idol">American Idol</option>
    <option value = "60 Minutes">60 Minutes</option>
    </select>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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