Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
how get multi options from multi selectbox in vue?

I have many select boxes that have many options and are dynamic.

<template>
  <div>
    <tr v-for="category in categories.items" :key="category.id">
      <td>
        <select v-model.trim="$v.form.attributeValues.$model" class="form-control">
          <option value=""></option>
          <option v-for="option in category.values" :key="option.id" :value="option">
            {{ option.content }}
          </option>
        </select>
      </td>
    </tr>
  </div>
</template>

<script>
export default {
  data() {
    return {
      categories: null,
      form: {
        productId: this.product.productId,
        attributeValues: [],
      },
    }
  },
}
</script>

I want get the values of theme and save it in an array.
But it doesn't work and I can only save 1 option.

like this: (get just one option from each selectbox) enter image description here

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

A multi-select is far from being a trivial a trivial component.

Most people simply use vue-multiselect or any package alike.
There is also a ton available only. You should look for the one matching your wanted features.

If you want to implement it manually, you will need to deal with binding the proper inputs, events and structure since it is not achievable with a simple v-model.
One of the best article on this is this one.

Still, it all depends on how you want it to look like, the behavior of the various options, the way to select it (keyboard, ctrl + click, simple click etc...), the transitions etc...

TLDR: use a package or try it yourself and show us what you achieved so far if you want some debugging.
The community will not write a complex component from scratch for you tho.

over 4 years ago · Santiago Trujillo Denunciar

0

Just put a v-model and a input-event to your option like this:

template

<option v-model="selectedItem" @input="checkItem(selectedItem)">
  <!-- Your code -->
</option>

Than go to your script and define everything. After that you can make a method called checkItem and there you will push everything in a defined array which you have selected.

script

data() {
  return {
    selectedItem: null,
    allItems: [],
  }
},

methods: {
  checkItem(selectedItem) {
    this.allItems.push(selectedItem)
  }
}

Hopefully this helps you out - pls let me know!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda