AnsweredAssumed Answered

onchange event is not firing on SELECT HTML TAG.

Question asked by SHI2R SHI2R on Mar 21, 2014
Latest reply on Mar 23, 2014 by Sagar Salunkhe
"onchange" event is not firing for SELECT html TAG.

I am using Sugar CE Version 6.5.16 (Build 1082).

editviewdefs.php:

The following definition does not work:
        3 =>        array (
          0 =>
          array (
            'name' => 'sales_stage',
            'label' => 'LBL_SALES_STAGE',
            'displayParams' =>
            array(
                'field' =>
                array (
                    'onchange' => 'ExtractPerc();',
                ),
            ),
          ),
          1 =>
          array (
            'name' => 'probability',
            'label' => 'LBL_PROBABILITY',
            'type' => 'readonly',
          ),
        ),


The Following definition works:

        3 =>        array (
          0 =>
          array (
            'name' => 'sales_stage',
            'label' => 'LBL_SALES_STAGE',
            'displayParams' =>
            array(
                'field' =>
                array (
                    'onfocus' => 'ExtractPerc();',
                    'onblur'  => 'ExtractPerc();',
                ),
            ),
          ),
The Javascript code is as follows:

function ExtractPerc(){
    var vNode = document.getElementById('sales_stage');
    var pSalesStage = vNode.options[vNode.selectedIndex].label;
    var vLen = pSalesStage.length;
    var vInd;
    var vNum = "";
    if (vLen > 0) {
        vInd = pSalesStage.lastIndexOf('(');
        while (!isNaN(pSalesStage[++vInd])) {
            vNum = vNum + pSalesStage[vInd];
        }
    }
    document.getElementById("probability").innerHTML = vNum;
}



Outcomes