locked
Enable a disabled Group by checkbox RRS feed

  • Question

  • any body have the code or the way to Disable list fields on checked box ?

    , Example form:

    1.Name?...

    2.Age?...

    3.Do you like apple? Yes\No

    Why......

    4. Do you like Red Color? Yes\No

     

     

    if you select No in Q.3, Why...... will enabled to fill it.

    Tuesday, February 19, 2008 9:03 PM

All replies

  • Take a look at this:-

     

    Code Snippet
    <html>
     <head>
      <script type="text/javascript">
      
    function chk_onchange()
    {
     var ctl = document.getElementById(this.getAttribute("enableWhenFalse"))
     
     ctl.disabled = this.checked
    }
      </script>
     </head>
     <body>
      <span>Like Apples?</span>
      <input type="checkbox" enableWhenFalse="txtApples"
        onchange="chk_onchange.call(this)"  />
      <br />
      <input id="txtApples" type="text" />
     </body>
    </html>

     

     

    Note that the chk_onchange function can be re-used for any checkbox that you want this behaviour for.  You just need to add the enableWhenFalse attribute to point to the control you want to disable when the check box is checked.
    Thursday, March 13, 2008 11:06 AM