如何在选择特定单选按钮时调用javascript?

<div id="dept-or-user-div" class="panel" style="padding-bottom:10px;">
    <h3 class="div-title">Select Alert Recipients</h3>
     <div class="recipient-error" style="display:none;"><p style="padding-top:10px; color:#f00;">Please select at least one recipient</p></div>

    <p>
        <input type="radio"  checked value="dept" name="user-or-dept">Department</input>
        <input type="radio"  value="user" name="user-or-dept">User</input>
        <input type="radio"  value="both" name="user-or-dept">Both</input>
    </p>
    <div class="department-select" class="dept">
        <p><label for="department-choice">Department:</label>
         <select name="department-choice" id="department-choice">
            <option></option>
            <?php
                echo get_departments();
            ?>
        </select></p>
    </div><!--end #department-select-->
    <div class="user-select user" >
        <p><label for="user-choice">User:</label> 

        <select name='user-choice' id="user-choice">
            <option></option>
            <?php
                echo get_users('option');
            ?>
        </select></p>

    </div><!--end #user-select--> 

</div><!--end #dept-or-user-div-->

Here i have three radio button

  1. Department (Department Dropdown)
  2. User(user dropdown)
  3. Both (user and department dropwon)

And what I want to do this when radio button with value "Both" i.e third radio button is selected, I want to call a js function and dynamically populate users dropdown depending department value. How can I do that?

Give it an id,

 <input type="radio"  id="both" value="both" name="user-or-dept">Both</input>

Then, using Jquery....do something like this...

 $('input#both').change(function(){

 if($(this).is(':checked')) {

 //do your ajax call here to retrieve values from database based on whatever criteria
 //and populate the result wherever you want
 $.ajax({
 url: "getdept.php",
 type: "POST",
 data: {type: "both"},
 dataType: "html",
 success: function(result){
  $('#department-choice').html(result);
 }
 }); 

}}

Then in that php file, something like...

$both = mysql_real_escape_string($_POST['type']);

$sql = "SELECT * FROM table WHERE dept = $both";
//dunno what your query will be, because I have no idea of your database
$res = mysql_query($sql);
while($row = mysql_fetch_array($res)){
  echo "<option>".$row['dept']."</option>";
}

This will output in the form of...

 <option>blah blah</option>
 <option>blah blah</option>
 <option>blah blah</option>

Which will insert into the select, dropdown, with that ajax above.