Hi All,
i’m using dynamic-form from wbraganca and trying to call function onchange event (javascript).
<?= $form->field($detail, "[{$i}]qty")->widget(\yii\widgets\MaskedInput::className(),
[
'clientOptions' => [
'alias' => 'numeric',
'groupSeparator' => ',',
'digits' => 0,
'autoGroup' => true,
'removeMaskOnSubmit' => true,
'rightAlign' => false,
],
'options' => [
'class' => 'form-control',
'onchange' => 'Info($(this))',
]
]) ?>
first method, i register javascript at the end of document like this
<?php
$script = <<< JS
function Info(item){
var index = item.attr("id").replace(/[^0-9.]/g, "");
alert(index);
};
JS;
$this->registerJs($script);
?>
this method not work because i got error "the function is not defined
and the second one, i register my js file in asset, it works.
What i want to know what is the differences?
Thanks before.