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
    Apr 2006
    Posts
    133
    Thanks
    6
    Thanked 0 Times in 0 Posts

    content changing and disabling the drop down menus

    Hi all,

    I have two drop down boxes next to each other with the same options

    <select name="view" class="style2">
    <option value="no" selected>N/A</option>
    <option value="forestview">Forest View</option>
    <option value="seaview">Sea View</option>
    <option value="lakeview">Lake View</option>
    <option value="mountainview">Mountain View</option>
    </select>

    I want the second one to be disabled when first one is N/A.
    If any other options are chosen in the first one I want the second one has all options except the option which is chosen on the first one.

    For example:

    if option Forest View is chosen in the first drop down menu. I want the second drop down appear like following:

    <select name="view2" class="style2">
    <option value="no" selected>N/A</option>
    <option value="seaview">Sea View</option>
    <option value="lakeview">Lake View</option>
    <option value="mountainview">Mountain View</option>
    </select>

    Any idea?

    Thanks

    Ceyhun

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,522
    Thanks
    3
    Thanked 508 Times in 495 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function Cng(obj,nme){
     document.getElementsByName(nme)[0].removeAttribute('disabled');
     if (obj.value=='no'){
      document.getElementsByName(nme)[0].setAttribute('disabled','disabled');
     }
    }
    //-->
    </script>
    </head>
    
    <body>
    
    <select name="view" class="style2" onchange="Cng(this,'view2');">
    <option value="no" selected>N/A</option>
    <option value="forestview">Forest View</option>
    <option value="seaview">Sea View</option>
    <option value="lakeview">Lake View</option>
    <option value="mountainview">Mountain View</option>
    </select>
    
    <select name="view2" class="style2" disabled="disabled" >
    <option value="no" selected>N/A</option>
    <option value="forestview">Forest View</option>
    <option value="seaview">Sea View</option>
    <option value="lakeview">Lake View</option>
    <option value="mountainview">Mountain View</option>
    </select>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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