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

    Disabling input field if radio not equal to yes..

    I have a text input field that I want disabled or readonly or whatever, unless the user selects the radio button with the value "yes"! How would I do this? Every attempt I have made has failed... I have very little skills when it comes to javascript!

    Thanks

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well im not sure what type of browser support it will have but this does the trick
    -----

    <script language="javascript">

    function check1(){
    if(document.form1.box1.checked==true){
    document.form1.input1.disabled=false
    }else{
    document.form1.input1.disabled=true
    }
    }
    window.onload=check1
    </script>

    <form name="form1">
    <input type="text" name="input1">
    <BR>
    <input type="radio" name="box1" onClick="check1()">
    </form>
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #3
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool thanks!


  •  

    Posting Permissions

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