Hi,
I want to pre select the inputdata in an active form.
7134
7135
I tried various "selected" with no success.
Is there a way to achieve this ?
Sven
Hi,
I want to pre select the inputdata in an active form.
7134
7135
I tried various "selected" with no success.
Is there a way to achieve this ?
Sven
You can do it with javascript/jQuery.
jQuery
$('#inputID').focus();
javascript
document.getElementById('inputID').focus();
Hi
Thank you for the quick reply.
I do have this coded
<?= $form->field($model, 'scanfeld_verknuepfen',['inputOptions' => [ 'autofocus' => 'autofocus', 'class' => 'form-control', 'tabindex' => '1'],])->input([
'placeholder' => 'Scan' ])->label('false'); ?>
I already use "autofocus". This does position the cursor, but it does not mark the input as selected.
So I ask, is there a difference between jQuery and the yii2 style coding?
Thanks in advance
Sven
You can do it,
In jQuery:
$('#inputID').focus();
$('#inputID').select();
In JavaScript:
var input = document.getElementById('inputID');
input.focus();
input.select();