Search code examples
javascriptsharepointsharepoint-2007sharepoint-list

Hide OK button based on radiobutton selection


I have a Sharepoint List with Radio-button field. If someone checks no then it should disable the ok button, but if yes is selected the ok button should be enabled. I need to write a javascript in CEWP to achieve this with no access to SPD, can some one please advise?


Solution

  • <script type = "text/javascript">
    function test_enable(id,id2)
    /*parameter "id" should be id of "no" radiobutton and "id2" is of yes button 
    */
    {
    if(document.getElementById(id).checked==true)
    {
    document.getElementById(id2).enabled==false;
    }
    else
    {
    document.getElementById(id2).enabled==true;
    }
    }
    </script>
    
    
    <input type = "radio" id = "id" onchange = "test_enable('id','id2')" value = "No">
    
    <input type = "button" id = "id2" onclick = "foo()" value = "click me!"> 
    

    Simple!