title: Call Javascript Function Based on Radio Button Checked Value
body: <p>I have a form that sets default values based on a user's account settings (stored in MySQL DB and pulled using PHP). When the form is displayed, it pulls the relevant account information and populates the form (First name, last name, email, account type, etc.)</p>
  
  <p>When a user's account type is 'admin' I want the rest of the form to become disabled, and have certain options selected. If the user's account type is 'admin', and therefore the 'edit_type_admin' radio button checked by default (see below) I would like to call the makeEditDisable() function below as the page is loaded (without requiring any clicks).</p>
  
  <p>Right now the form displays the account type as follows:</p>
  
  <pre><code>Client or Admin: &lt;br /&gt;
  Client &lt;input type="radio" name="edit_type" id="edit_type_client" value="client" &lt;? if($selected_type == 'client') { echo 'checked'; } ?&gt; onclick="makeEditEnable()" /&gt;
  Admin &lt;input type="radio" name="edit_type" id="edit_type_admin" value="admin" &lt;? if($selected_type == 'admin') { echo 'checked'; } ?&gt; onclick="makeEditDisable()" /&gt;
  </code></pre>
  
  <p>When toggling between the two options the onclick makeEditEnable()/makeEditDisable() functions work correctly:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
            function makeEditDisable(){
                var x=document.getElementById("edit_access_begin")
                x.disabled=true;
                var x=document.getElementById("edit_access_expire")
                x.disabled=true;
                var x=document.getElementById("edit_project_access_yes")
                x.checked=true;
                var x=document.getElementById("edit_project_access_yes")
                x.disabled=true;
                var x=document.getElementById("edit_project_access_no")
                x.disabled=true
            }
           function makeEditEnable(){
              var x=document.getElementById("edit_access_begin")
              x.disabled=false;
              var x=document.getElementById("edit_access_expire")
              x.disabled=false;
              var x=document.getElementById("edit_project_access_yes")
              x.disabled=false;
              var x=document.getElementById("edit_project_access_no")
              x.disabled=false
           }&lt;/script&gt;
  </code></pre>