nomac
(A Pani)
1
Hello.
Is there a way to add a javascript, based on an event (onclick, onchange…)
to a $form->field ?
And it is a normal textInput, no Dropdown!
<?= $form->field($detail, 'vacancy_lat')->textInput(['maxlength' => true]) ?>
I’m also looking for the same with a HTML::helper field
echo yii\helpers\Html::textInput('lon', $lon, ['id' => 'lon'])
Thank you.
amit5992
(Gupta5992amit)
2
You can try this…
<?= $form->field($detail, 'vacancy_lat')->textInput(['maxlength' => true, 'onclick' => 'js:alert("Clicked me");' ]) ?>
you can use function() in ‘onclick’ attribute like
'onclick' => 'js:function(this.value) { alert(this.value); }'
1 Like
nomac
(A Pani)
3
Thank you, it works!
And for a HTML::helper field:
echo yii\helpers\Html::textInput('lon', $lon, ['id' => 'lon','onclick' => 'alert("Clicked me")']);