title: how to get selected value from a option set crm 4 dynamics 2011 online
body: <p>This is a question related to using javascript with crm 4 2011 online</p>
  
  <p>I created an optionset -status: open,closed and a onchange event handler that calls the function run with the context as parameter.</p>
  
  <p>In js i tried the following and more:</p>
  
  <pre><code>function run(selectedItems)
  {
      var s = selectedItems[0];
  }
  </code></pre>
  
  <p>But i always get an undefined variable.</p>
  
  <p>How can get the selected value from a optionset?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>i tried </p>
  
  <pre><code>function run() { 
  alert("hello"); 
  var texter = Xrm.Page.getAttribute("new_state_request").getSelectedOption().text; 
  alert(texter); 
  } 
  </code></pre>
  
  <p>just now. Gettin this: 
  Error in userdefined event of this field. 
  field:new_state_request 
  event:onchange 
  error:undefined</p>