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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Enable a dropdown from value of a drop down

    I have two dropdowns (lets call them A and B), A is enabled and B is disabled. If I choose a specific option from A, then B will be enabled, but if I change the option on A to somthing else, B will turn disabled. Any ideas, I tried:

    Code:
    function EnableDisable(){
    if ( document.myform.StandinPinCheckYes.value = "Risk Record")
    {
    document.myform.PinOffsetGeneration.disable=false
    }
    else
    {
    document.myform.PinOffsetGeneration.disable
    }
    }
    and calling it from dropdown A by:

    Code:
    <select name="somthing" id="somthing" onchange="EnableDisable()">

  • #2
    Regular Coder RexxCrow's Avatar
    Join Date
    Jul 2006
    Location
    California
    Posts
    275
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Here is some good info:

    http://www.tjhsst.edu/~dhyatt/superap/forms.html

    http://www.hyper gurl.com/example2.html
    (del the space between the hypergurl, it gets asterisked out for some reason.)
    Last edited by RexxCrow; 07-28-2006 at 09:19 PM.

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Those are resources about HTML and Forms. How is those relavant to this problem?

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    
    function Dis(obj){
     if (!window['zxc'+obj.id]){ window['zxc'+obj.id]=''; }
     var val=obj.value.split(',');
     for (var zxc0=0;zxc0<val.length;zxc0++){
      if (!window['zxc'+obj.id].match(val[zxc0])){ window['zxc'+obj.id]+=val[zxc0]+','; }
     }
     var enable=window['zxc'+obj.id].split(',');
     for (var zxc1=0;zxc1<enable.length;zxc1++){
      var eobj=document.getElementById(enable[zxc1]);
      if (eobj){
       eobj.removeAttribute('disabled');
      }
     }
     for (var zxc2=0;zxc2<val.length;zxc2++){
      eobj=document.getElementById(val[zxc2]);
      if (eobj){
       eobj.setAttribute('disabled','disabled');
      }
     }
    
    
    
    }
    
    /*]]>*/
    </script>
    </head>
    
    <body>
    <select id="S1" onchange="Dis(this);">
    <option value="" >Option 0</option>
    <option value="S2," >Option 1</option>
    <option value="" >Option 2</option>
    </select>
    
    <select id="S2" >
    <option value="" >Option 0</option>
    <option value="" >Option 1</option>
    <option value="" >Option 2</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/

  • #5
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Vic, but that is the oposite of what I need.

    I have the following code:

    Code:
    <script language="javascript">
    function EnableDisable(){
    if ( document.myform.StandinPinCheckYes.value = "Risk Record")
    {
    document.myform.PinOffsetGeneration.disabled=false
    }
    else
    {
    document.myform.PinOffsetGeneration.disabled
    }
    }
    </script>
    And Calling it like:

    Code:
    <select name="StandinPinCheckYes" id="StandinPinCheckYes" class="txtbox" onChange="EnableDisable()">
    	<option value="">&nbsp;</option>
    	<option value="Risk Record">Pin/Offset Included on Risk Record</option>
    	<option value="Track of Card">Pin/Offset Included on Track of Card</option>
    </select>
    to enable or disable:

    Code:
    <select name="PinOffsetGeneration" id="PinOffsetGeneration" class="txtbox">
    	<option value="">&nbsp;</option>
    	<option value="Negative Batch File">Negative Batch File</option>
    	<option value="Host Function">Host Function</option>
    	<option value="Online Message">Online Message</option>
    </select>
    Initially, the dropdown 'PinOffsetGeneration' is disabled from another function (called when the page loads) when 'Risk Record' is selected from the 'StandinPinCheckYes' dropdown, the 'PinOffsetGeneration' dropdown is enabled (but disabled again when a different option is selected from the 'StandinPinCheckYes' dropdown.
    Last edited by neilc; 08-01-2006 at 03:56 PM.

  • #6
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    you need
    Code:
    if ( document.myform.StandinPinCheckYes.value == "Risk Record")

  • #7
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    
    function Dis(obj){
     if (!window['zxc'+obj.id]){ window['zxc'+obj.id]=''; }
     var val=obj.value.split(',');
     for (var zxc0=0;zxc0<val.length;zxc0++){
      if (!window['zxc'+obj.id].match(val[zxc0])){ window['zxc'+obj.id]+=val[zxc0]+','; }
     }
     var enable=window['zxc'+obj.id].split(',');
     for (var zxc1=0;zxc1<enable.length;zxc1++){
      var eobj=document.getElementById(enable[zxc1]);
      if (eobj){
       eobj.setAttribute('disabled','disabled');
      }
     }
     for (var zxc2=0;zxc2<val.length;zxc2++){
      eobj=document.getElementById(val[zxc2]);
      if (eobj){
       eobj.removeAttribute('disabled');
      }
     }
    }
    
    /*]]>*/
    </script>
    </head>
    
    <body>
    <select id="S1" onchange="Dis(this);">
    <option value="" >Option 0</option>
    <option value="S2," >Option 1</option>
    <option value="" >Option 2</option>
    </select>
    
    <select id="S2" disabled="disabled" >
    <option value="" >Option 0</option>
    <option value="" >Option 1</option>
    <option value="" >Option 2</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
    •