title: Dynamically generated dropdown in Wordpress options page
body: <p>I've got a plugin I'm working on, part of which consists of a 'conditional' dropdown on the options page. Basically, I've got a dropdown with three options, and a second dropdown gets populated with info from the database depending on what is selected in the first dropdown. Problem is, I'm at a loss as to how to populate the second dropdown! I'm not really that great with AJAX, but it seems the likely solution. Any thoughts from the more seasoned devs out here?</p>
  
  <p>EDIT: Here's where I currently am, but it never seems to get run:</p>
  
  <pre><code>&lt;form action="&lt;?php echo site_url() ?&gt;/wp-admin/admin.php?page=ad_manager&amp;pagetype=addedit&amp;pid=&lt;?php echo $_REQUEST['id']; ?&gt;" method="post" name="ad_success"&gt;
      &lt;table cellpadding="5" class="widefat post fixed"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;&lt;strong&gt;&lt;?php if($_REQUEST['id'] != '') { _e('Edit Ad'); } else { _e('Create Ad'); } ?&gt;&lt;/strong&gt;&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;label for="gtad_condition"&gt;
                          &lt;strong&gt;&lt;?php _e('Ad Condition'); ?&gt;:&lt;/strong&gt;
                          &lt;select name="ad_condition" id="ad_condition"&gt;
                              &lt;option value=""&gt;Select an option...&lt;/option&gt;
                              &lt;option value="is_city"&gt;Is City&lt;/option&gt;
                              &lt;option value="is_location"&gt;Is Location&lt;/option&gt;
                              &lt;option value="is_page"&gt;Is Page&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/label&gt;
                      &lt;label for="gtad_location"&gt;
                          &lt;select name="ad_location" id="ad_location"&gt;&lt;/select&gt;
                      &lt;/label&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
      jQuery(document).ready(function() {
          $ad_condition = $("select[name='ad_condition']");
          $ad_location = $("select[name='ad_location']");
  
          $ad_condition.change(function() {
              if ($(this).val() == "Is City") {
                  $("select[name='ad_location'] option").remove();
                  $("&lt;option&gt;Test&lt;/option&gt;").appendTo($ad_location);
              }
          });
      });
  &lt;/script&gt;
  </code></pre>