<!--
 ! Excerpted from "Rails Recipes"
 ! We make no guarantees that this code is fit for any purpose. 
 ! Visit http://www.pragmaticprogrammer.com/titles/fr_rr for more book information.
-->
<html>
<head>
  <script src="javascripts/prototype.js" type="text/javascript"></script>
  <script src="javascripts/effects.js" type="text/javascript"></script>
  <script src="javascripts/dragdrop.js" type="text/javascript"></script>
  <script src="javascripts/controls.js" type="text/javascript"></script>
  <script language="JavaScript">
    Ajax.InPlaceSelectEditor = Class.create();
    Object.extend(Object.extend(Ajax.InPlaceSelectEditor.prototype, Ajax.InPlaceEditor.prototype), {
        createEditField: function() {
          var text;
          if(this.options.loadTextURL) {
            text = this.options.loadingText;
          } else {
            text = this.getText();
          }
          this.options.textarea = false;
          var selectField = document.createElement("select");
          selectField.name = "value";
          selectField.innerHTML=this.options.selectOptionsHTML || "<option>" + text + "</option>";
          $A(selectField.options).each(function(opt, index){
            if(text == opt.value) {
              selectField.selectedIndex = index;
            }
          }
          );
            selectField.style.backgroundColor = this.options.highlightcolor;
            this.editField = selectField;
          if(this.options.loadTextURL) {
            this.loadExternalText();
          }
          this.form.appendChild(this.editField);
        }
    });
  </script>
</head>
<body>
  <span id="an_editor">Chad Fowler</span>
  <script type="text/javascript">
  //<![CDATA[
    new Ajax.InPlaceSelectEditor('an_editor', '/contacts/set_contact_name/1', {selectOptionsHTML: '<option>foo</option><option>Chad Fowler</option><option>x</option>'})
  //]]>
  </script>
  <%= in_place_select_editor_field(:contact, :country, nil, {:select_options => country_options_for_select}) %>
 </body>
</html>