Monday, April 30, 2018

yii2 dropdownlist onchange

Dropdownlist onchange example is showing below. In dropdownlist first attribute is $name ,second attribute should be null, third attribute is $items array and fourth attribute is $options. In this example we are using a callAFunction() on onchange method.

Yii2 Html dropdownlist onchange

use yii\helpers\Html;
Html::beginForm()
Html::dropDownList(
    'username', 
    'null',
    ['1'=>'abc', '2'=>'xyz'],
    ['onchange'=>'callAFunction()']);
 Html::endForm()

//Javascript function
function callAFunction(){
alert('I am here');
}


1 comment:

Recent Update

yii2 session handling

use yii\web\Session; $session = Yii::$app->session; // start session $session->open(); // close session $session->close(); ...

Most Search