title: HOW TO: Changing Dropdown Value in SugarCRM
body: <p>I'm trying to change the value of a dropdown list via a click of a button, I'm using SugarCRM CE 6.5, and here's the problem I encoutered:</p>
  
  <p><a href="https://i.stack.imgur.com/WL4eJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WL4eJ.png" alt="enter image description here"></a></p>
  
  <p>And here's my code below:</p>
  
  <p>-- detailviewdefs.php</p>
  
  <pre><code>&lt;?php
  $module_name = 'UA_Quotes';
  $viewdefs [$module_name] = 
  array (
  'DetailView' =&gt; 
  array (
   'templateMeta' =&gt; 
  array (
    'include' =&gt; 
     array (
      0 =&gt;
      array (
        'file' =&gt; 
        'custom/modules/UA_Quotes/JS/clickPayment.js',
        ),
      ),
    'form' =&gt; 
    array (
      'closeFormBeforeCustomButtons' =&gt; true,
      'buttons' =&gt; 
      array (
        0 =&gt; 'EDIT',  
        1 =&gt; 'DELETE',
        2 =&gt; 
        array (
          'customCode' =&gt; '{$Monthly_Payment}',
        ),
      ),
      'footerTpl' =&gt; 'modules/UA_Quotes/tpls/DetailViewFooter.tpl',
    ),
    'maxColumns' =&gt; '2',
    'widths' =&gt; 
    array (
      0 =&gt; 
      array (
        'label' =&gt; '10',
        'field' =&gt; '30',
      ),
      1 =&gt; 
      array (
        'label' =&gt; '10',
        'field' =&gt; '30',
      ),
    ),
    'useTabs' =&gt; false,
    'tabDefs' =&gt; 
    array (
      'LBL_EDITVIEW_PANEL2' =&gt; 
      array (
        'newTab' =&gt; false,
        'panelDefault' =&gt; 'expanded',
      ),
    ),
  ),
  'panels' =&gt; 
  array (
    'lbl_editview_panel2' =&gt; 
    array (
      0 =&gt; 
      array (
        0 =&gt; 'name',
        1 =&gt; 
        array (
          'name' =&gt; 'ua_contracts_ua_quotes_1_name',
        ),
      ),
      1 =&gt; 
      array (
        0 =&gt; 
        array (
          'name' =&gt; 'monthlystart_c',
          'label' =&gt; 'LBL_MONTHLYSTART',
        ),
        1 =&gt; 
        array (
          'name' =&gt; 'quote_stage',
          'studio' =&gt; 'visible',
          'label' =&gt; 'LBL_QUOTE_STAGE',
        ),
      ),
      2 =&gt; 
      array (
        0 =&gt; 
        array (
          'name' =&gt; 'monthlydeadline_c',
          'label' =&gt; 'LBL_MONTHLYDEADLINE',
        ),
      ),
    ),
  ),
  ),
  );
  ?&gt;
  </code></pre>
  
  <p>-- view.detail.php</p>
  
  <pre><code>&lt;?php
  
  
  require_once('include/MVC/View/views/view.detail.php');
  
  class UA_QuotesViewDetail extends ViewDetail
  {
  public function __construct()
  {
      parent::ViewDetail();
  }
  
  public function display()
  {
      echo '&lt;script type="text/javascript"    src="custom/modules/UA_Quotes/js/clickPayment.js"&gt;&lt;/script&gt;';
      $groups = $this-&gt;bean-&gt;Get_Products($this-&gt;bean-&gt;id, true);
      $this-&gt;ss-&gt;assign('GROUPS', $groups);
  
      $this-&gt;ss-&gt;assign('NET_TOTAL', currency_format_number($this-&gt;bean-&gt;net_total_amount));
      $this-&gt;ss-&gt;assign('TOTAL', currency_format_number($this-&gt;bean-&gt;total_amount));
      $this-&gt;ss-&gt;assign('Monthly_Payment', '&lt;input type="button" onclick="GetPayment();" value="Monthly Payment"/&gt;');
      /*
      $this-&gt;dv-&gt;ss-&gt;assign('Monthly_Payment', '&lt;input type="button" 
      onclick="alert(\'How to change status :(\')" value="Monthly Payment"/&gt;');*/
  
      parent::display();
  }
  }
  </code></pre>
  
  <p>-- clickPayment.js</p>
  
  <pre><code>function GetPayment(){
  
  var record = $("#record").val();
  // var pathArray = window.location.href.split("=");
  var fdata = { 'record':record };   
  // console.log(pathArray[3]," - your Record ID");
  $.ajax({
                      type: 'POST',                 
                      url: "custom/modules/UA_Quotes/js/changestatus.php?&amp;fdata="+fdata+"",
                      data: fdata, //{recordID: pathArray[3]},
                      dataType: 'html',
                      async: false,
                      error: function(resp){},
                      success: function(resp){
                          location.reload(true);
                      }                     
                      /*  success:function(fdata){                     
                          console.log("Customer Status Change"); 
                           location.reload(true);        
                      },
                      error: function(fdata) {
                          // if error occured
                          console.log(" NA ");                     
                      }   */
                  });
  }
  </code></pre>
  
  <p>-- and finally, my changestatus.php</p>
  
  <pre><code>&lt;?php
  
  $myrecordID = $_POST['record'];
  $focus = new UA_Quotes();
  $focus-&gt;retrieve($myrecordID);
  $focus-&gt;quote_stage_dom = 'Paid';
  
  ?&gt;
  </code></pre>
  
  <p>I am very sorry for the long post of codes, I've been dealing with 'em for a couple of days now, and seems to be of no luck. :(
  Any help could be appreciated! Thank you!</p>