This is my form code:
<?= $form->field($model, 'stdclass_id')->dropDownList($stdclassArray,
['prompt' => 'Select','id' => 'selectedclass'])->label('Class') ?>
<?= $form->field($model, 'session_id')->dropDownList($sessionArray,
['prompt' => 'Select', 'id' => 'selectedsession',])->label('Session') ?>
<?= $form->field($model, 'roll_no')->textInput(['maxlength' => true, 'id' => 'roll']) ?>
And this is the jQuery part of the form:
$script = <<< JS
$('#selectedsession').on('change',function(){
var value1 = document.getElementById("selectedclass").value;
var value2 = document.getElementById("selectedsession").value;
$.ajax({
url: '<?php echo Yii::$app->request->baseUrl. '/enrollment/rollno' ?>',
type: "POST",
data: { value1: value1, value2 : value2 },
success: function(data) {
var abc = data;
$("#roll").val(abc);
}
});
});
JS;
This produces the following error:
Undefined Variable: app
I'm not able to use yii::$app.