Answer the question
In order to leave comments, you need to log in
How to make inactive select on vue?
Good day!
I want to implement select with an inactive field , also add that the field is required .
At the moment, there are default data that I wrote in vue. If the client accidentally clicks submit, false information is entered into the database. This option is not suitable.
Disappears immediately after page refresh.
<option selected disabled required>Выберите что-то</option>
<div class="form-group">
<select name="Course" id="Course" required class="form-control" v-model="selected.list1">
<option v-for="option in list1" :value="option.id" v-text="option.Title" />
</select>
</div>
<div class="form-group">
<select name="MorningEvening" id="MorningEvening" required class="form-control" v-model="selected.list2">
<option v-for="option in list2Select" :value="option.id" v-text="option.Title" />
</select>
</div>
new Vue({
el: "#app",
data: {
list1: [ { id: 1, Title: 'Выбор 1' }, { id: 2, Title: 'Выбор 2' }, { id: 3, Title: 'Выбор 3' } ],
list2: [
{ id: 1, idForeign: 1, Title: '1' },
{ id: 2, idForeign: 2, Title: '2' },
{ id: 3, idForeign: 2, Title: '3' },
],
selected: {
list1: 1,
list2: 1,
},
},
computed: {
list2Select() {
return this.list2.filter( option => option.idForeign == this.selected.list1 )
}
},
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question